DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
PlayerContainer.c
См. документацию.
2{
8
9 protected const int HEADER_INDEX_OFFSET = 2;
10
11 override void UpdateRadialIcon()
12 {
13 if ( m_SlotIcon )
14 {
15 bool show_radial_icon;
16 show_radial_icon = IsHidden();
17 Widget rip = m_SlotIcon.GetRadialIconPanel();
18 rip.Show( !m_Player.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) && m_Player.CanDisplayCargo());
19 SetOpenForSlotIcon(show_radial_icon);
20 }
21 }
22
24 {
25 ClosableContainer cont = ClosableContainer.Cast( m_ShowedItems.Get( entity ) );
26 return ( cont && cont.IsOpened() );
27 }
28
29 SlotsIcon GetSlotsIcon( int row, int column )
30 {
31 return m_PlayerAttachmentsContainer.GetSlotsIcon(row, column);
32 }
33
34 void PlayerContainer( LayoutHolder parent, int sort = -1 )
35 {
38
39 #ifndef PLATFORM_CONSOLE
40 RightArea rightArea = RightArea.Cast(GetParent());
41 if (rightArea)
42 {
43 rightArea.GetSlotsArea().AddChild(GetHeader().GetRootWidget());
44 rightArea.GetSlotsArea().AddChild(m_PlayerAttachmentsContainer.GetRootWidget());
45 }
46 #endif
47
49 m_CollapsibleHeader.SetName( "#container_inventory" );
50 SetHeader(null);
51 m_Body.Insert( m_PlayerAttachmentsContainer );
52 m_MainWidget = m_RootWidget.FindAnyWidget( "body" );
53 m_PlayerAttachmentsContainer.GetRootWidget().SetColor(166 << 24 | 80 << 16 | 80 << 8 | 80);
54 WidgetEventHandler.GetInstance().RegisterOnChildAdd( m_MainWidget, this, "OnChildAdd" );
55 WidgetEventHandler.GetInstance().RegisterOnChildRemove( m_MainWidget, this, "OnChildRemove" );
56
57 //START - InitGhostSlots
58 string config_path_ghosts_slots = "CfgVehicles SurvivorBase InventoryEquipment playerSlots";
59 ref array<string> player_ghosts_slots = new array<string>;
60 GetGame().ConfigGetTextArray( config_path_ghosts_slots, player_ghosts_slots );
61
62 for ( int i = 0; i < player_ghosts_slots.Count(); i++ )
63 {
64 string slot_name = player_ghosts_slots.Get ( i );
65 string path = "CfgSlots" + " " + slot_name;
66
67 if ( GetGame().ConfigIsExisting( path ) )
68 {
69 string icon_name; //icon_name must be in format "set:<setname> image:<imagename>"
70 GetGame().ConfigGetText( path + " ghostIcon", icon_name );
71 int slot_number = i;
72 int column = slot_number % ITEMS_IN_ROW;
73
74 //START - GetWidgetSlot
75 int row = slot_number / ITEMS_IN_ROW;
76 if( row >= m_PlayerAttachmentsContainer.Count() )
77 {
78 if( row < ( player_ghosts_slots.Count() / ITEMS_IN_ROW ) )
80 else
81 AddSlotsContainer( player_ghosts_slots.Count() % ITEMS_IN_ROW );
82 }
83
84 SlotsIcon icon = GetSlotsIcon( row, column );
85
86 icon.GetMainWidget().Show( true );
87 icon.Clear();
88
90
91 //END - GetWidgetSlot
92 WidgetEventHandler.GetInstance().RegisterOnDropReceived( icon.GetPanelWidget(), this, "OnDropReceivedFromGhostArea" );
93 WidgetEventHandler.GetInstance().RegisterOnDropReceived( icon.GetGhostSlot(), this, "OnDropReceivedFromGhostArea" );
94 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( icon.GetGhostSlot(), this, "DraggingOver" );
97
99 //END - LoadIconIntoWidgetSlot
100
101 GetGame().ConfigGetText( path + " name", slot_name );
102 int slot_id = InventorySlots.GetSlotIdFromString( slot_name );
103 icon.SetSlotID(slot_id);
105 m_InventorySlots.Set( slot_id, icon );
106 }
107 }
108 m_PlayerAttachmentsContainer.GetMainWidget().Update();
109 //END - InitGhostSlots
110 RecomputeOpenedContainers();
111 }
112
114 {
115 if( m_Player )
116 {
117 m_Player.GetOnItemAttached().Remove(ItemAttached);
118 m_Player.GetOnItemDetached().Remove(ItemDetached);
119 m_Player.GetOnAttachmentSetLock().Remove(OnAttachmentReservationSet);
120 m_Player.GetOnAttachmentReleaseLock().Remove(OnAttachmentReservationRelease);
121 }
122 }
123
124 void ItemAttached(EntityAI item, string slot_name)
125 {
126 int slot = InventorySlots.GetSlotIdFromString( slot_name );
127 SlotsIcon icon = m_InventorySlots.Get( slot );
128
129 if( icon )
130 {
131 if( icon.IsReserved())
132 m_Player.GetOnAttachmentReleaseLock().Invoke(item, slot);
133
134 icon.Init( item );
135
136 if( m_ShowedItems.Contains( item ) == false )
137 {
138 string name;
139 int sort_index = Inventory.GetPlayerAttachmentIndex( slot );
140 int current_sort = 9999;
141 if( GetFocusedContainer() )
142 current_sort = GetFocusedContainer().GetRootWidget().GetSort();
143
144 if( item.GetSlotsCountCorrect() > 0 )
145 {
146 ContainerWithCargoAndAttachments iwca = new ContainerWithCargoAndAttachments( this, sort_index );
147 iwca.SetEntity( item );
148 iwca.SetSlotIcon( icon );
150
151 if( iwca.IsDisplayable() )
152 {
153 icon.GetRadialIconPanel().Show( true );
154 }
155 m_ShowedItems.Insert( item, iwca );
156 RecomputeOpenedContainers();
157 Refresh();
158 }
159 else if( item.GetInventory().GetCargo() )
160 {
161 ContainerWithCargo iwc = new ContainerWithCargo( this, sort_index );
162 iwc.SetEntity( item );
163 iwc.SetSlotIcon( icon );
164 iwc.UpdateInterval();
166 m_ShowedItems.Insert( item, iwc );
167 RecomputeOpenedContainers();
168 if( iwc.IsDisplayable() )
169 icon.GetRadialIconPanel().Show(true);
170
171 Refresh();
172 }
173 }
174
175 ClosableContainer conta = ClosableContainer.Cast( m_ShowedItems.Get( item ) );
176 string config = "CfgVehicles " + item.GetType() + " GUIInventoryAttachmentsProps";
177 if( conta && conta.IsInherited( ClosableContainer ) )
178 {
179 bool show_radial_icon = ( item.GetInventory().GetCargo() || item.GetSlotsCountCorrect() > 0 ) && !GetGame().ConfigIsExisting( config );
180 Widget rip = icon.GetRadialIconPanel();
181
182 rip.Show( show_radial_icon );
183 SetOpenForSlotIcon(conta.IsOpened(),icon);
184 }
185 }
186 UpdateSelectionIcons();
187 }
188
189 void ItemDetached(EntityAI item, string slot_name)
190 {
191 int slot = InventorySlots.GetSlotIdFromString( slot_name );
192 SlotsIcon icon = m_InventorySlots.Get( slot );
193
194 if( icon )
195 {
196 Container con = m_ShowedItems.Get( item );
197 if( con )
198 {
199 ( Container.Cast( con.m_Parent ) ).Remove( con );
200 RecomputeOpenedContainers();
201 GetMainWidget().Update();
202 Refresh();
203 m_ShowedItems.Remove( item );
204 }
205
206 icon.Clear();
207 Inventory in = Inventory.Cast( GetRoot() );
208 if( in )
209 in.UpdateConsoleToolbar();
210 }
211 UpdateSelectionIcons();
212 }
213
214 void OnAttachmentReservationSet( EntityAI item, int slot_id )
215 {
216 SlotsIcon icon = m_InventorySlots.Get( slot_id );
217
218 if( item )
219 {
220 icon.Init( item, true );
221 }
222 }
223
224 void OnAttachmentReservationRelease( EntityAI item, int slot_id )
225 {
226 SlotsIcon icon = m_InventorySlots.Get( slot_id );
227 icon.Clear();
228 }
229
230 void AddSlotsContainer( int row_count )
231 {
233 container.SetColumnCount(row_count);
234 m_PlayerAttachmentsContainer.Insert(container);
235 }
236
237 void MouseClick( Widget w, int x, int y, int button )
238 {
239 SlotsIcon icon;
240 w.GetUserData(icon);
241
242 ItemBase selectedItem;
243 bool isReserved;
244
245 if (icon)
246 {
247 selectedItem = ItemBase.Cast(icon.GetEntity());
248 isReserved = icon.IsReserved();
249
250 }
251
252 if (selectedItem)
253 {
254 switch (button)
255 {
256 case MouseState.RIGHT:
257 #ifdef DIAG_DEVELOPER
258 if (GetDayZGame().IsLeftCtrlDown())
259 ShowActionMenu(selectedItem);
260 #endif
261
262 if (isReserved)
263 {
264 GetGame().GetPlayer().GetHumanInventory().ClearUserReservedLocationSynced(selectedItem);
265 m_Player.GetOnAttachmentReleaseLock().Invoke(selectedItem, icon.GetSlotID());
266 }
267 break;
268
269 case MouseState.MIDDLE:
270 if (!isReserved)
271 InspectItem(selectedItem);
272
273 break;
274
275 case MouseState.LEFT:
276 if (!isReserved)
277 {
278 PlayerBase controlledPlayer = PlayerBase.Cast(GetGame().GetPlayer());
279 if (g_Game.IsLeftCtrlDown())
280 {
281 if (controlledPlayer.CanDropEntity(selectedItem))
282 {
283 if (selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
284 selectedItem.SplitIntoStackMaxClient(null, -1);
285 else
286 controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
287 }
288 }
289 else
290 {
291 bool draggable = !m_Player.GetInventory().HasInventoryReservation(selectedItem, null ) && !m_Player.GetInventory().IsInventoryLocked() && selectedItem.GetInventory().CanRemoveEntity() && !m_Player.IsItemsToDelete();
293 }
294 }
295 break;
296 }
297 }
298 }
299
301 {
302 float x, y;
303 GetRootWidget().GetScreenPos( x, y );
304 return y;
305 }
306
308 {
309 float x, y;
310 float x2, y2;
311 GetRootWidget().GetScreenPos( x, y );
312 GetRootWidget().GetScreenSize( x2, y2 );
313 y += y2;
314 return y;
315 }
316
317 override void Insert( LayoutHolder container, int pos = -1, bool immedUpdate = true )
318 {
319 ClosableContainer c_cont = ClosableContainer.Cast( container );
320 if (c_cont && m_Body.Count() > 1)
321 {
322 ClosableContainer prev = ClosableContainer.Cast(m_Body.Get( 1 ));
323 int index = 1;
324 int curr_sort = c_cont.GetRootWidget().GetSort();
325 while ( prev )
326 {
327 int prev_sort = prev.GetRootWidget().GetSort();
328 if ( prev_sort > curr_sort )
329 break;
330
331 if ( ++index < m_Body.Count() )
332 prev = ClosableContainer.Cast( m_Body.Get( index ) );
333 else
334 break;
335 }
336
337 m_Body.InsertAt( container, index );
338 }
339 else
340 {
341 m_Body.Insert( container );
342 }
343
344 if ( immedUpdate )
345 RecomputeOpenedContainers();
346 }
347
349 {
350 EntityAI ent = GetFocusedItem();
351 return ent && ( ent.GetInventory().GetCargo() || ent.GetSlotsCountCorrect() > 0 );
352 }
353
355 {
356 EntityAI ent = GetFocusedItem();
357 return ent && QuantityConversions.HasItemQuantity( ent ) && ent.CanBeSplit();
358 }
359
360 override bool IsItemActive()
361 {
362 EntityAI ent = GetFocusedItem();
364 }
365
367 {
368 EntityAI ent = GetFocusedItem();
369 return ent == null;
370 }
371
376
377 void DoubleClick(Widget w, int x, int y, int button)
378 {
379 if( button == MouseState.LEFT && !g_Game.IsLeftCtrlDown())
380 {
381 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
382
383 if( w == null || m_Player.GetInventory().IsInventoryLocked() )
384 {
385 return;
386 }
387 ItemPreviewWidget iw = ItemPreviewWidget.Cast( w.FindAnyWidget( "Render" ) );
388 if( !iw )
389 {
390 string name = w.GetName();
391 name.Replace( "PanelWidget", "Render" );
392 iw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
393 }
394 if( !iw )
395 {
396 iw = ItemPreviewWidget.Cast( w );
397 }
398
399 ItemBase item = ItemBase.Cast( iw.GetItem() );
400
401 if( !item )
402 {
403 return;
404 }
405
406 SlotsIcon icon;
407 iw.GetUserData(icon);
408
409 if(icon && icon.IsReserved())
410 {
411 return;
412 }
413
414 if( !item.GetInventory().CanRemoveEntity() )
415 return;
416
417 if ( player.GetInventory().HasEntityInInventory( item ) && player.GetHumanInventory().CanAddEntityInHands( item ) )
418 {
419 player.PredictiveTakeEntityToHands( item );
420 }
421 else
422 {
423 if (player.GetInventory().CanAddEntityToInventory( item ) && item.GetInventory().CanRemoveEntity())
424 {
425 if( item.GetTargetQuantityMax() < item.GetQuantity() )
426 item.SplitIntoStackMaxClient( player, -1 );
427 else
428 player.PredictiveTakeEntityToInventory( FindInventoryLocationType.ANY, item );
429 }
430 else
431 {
432 if( item.GetTargetQuantityMax() < item.GetQuantity() )
433 item.SplitIntoStackMaxHandsClient( player );
434 else
435 player.PredictiveTakeEntityToHands( item );
436 }
437 }
438 ToggleWidget( w );
439 HideOwnedTooltip();
440
441 InventoryMenu menu = InventoryMenu.Cast( GetGame().GetUIManager().FindMenu( MENU_INVENTORY ) );
442 if ( menu )
443 {
444 menu.RefreshQuickbar();
445 }
446 }
447 }
448
450 {
451 if( m_PlayerAttachmentsContainer.IsActive() )
452 {
453 ToggleWidget(m_PlayerAttachmentsContainer.GetFocusedSlotsIcon().GetPanelWidget());
454 }
455 }
456
458 {
459 return GetFocusedContainer().IsInherited( ContainerWithCargo );
460 }
461
463 {
464 return GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments );
465 }
466
468 {
469 if (CanDrop())
470 {
471 if (GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ))
472 {
473 return GetFocusedContainer().TransferItemToVicinity();
474 }
475 else
476 {
477 Man player = GetGame().GetPlayer();
478 ItemBase item = ItemBase.Cast(GetFocusedItem());
479 if ( item && player.CanDropEntity( item ) )
480 {
481 if ( item.GetTargetQuantityMax() < item.GetQuantity() )
482 item.SplitIntoStackMaxClient( null, -1 );
483 else
484 player.PhysicalPredictiveDropItem( item );
485 return true;
486 }
487 }
488 }
489 return false;
490 }
491
492 override bool InspectItem()
493 {
494 if( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
495 {
496 return GetFocusedContainer().InspectItem();
497 }
498 else
499 {
500 Man player = GetGame().GetPlayer();
501 EntityAI item = GetFocusedItem();
502 if( item )
503 {
504 InspectItem( item );
505 return true;
506 }
507 }
508 return false;
509 }
510
511 int GetRecipeCount( bool recipe_anywhere, EntityAI entity1, EntityAI entity2 )
512 {
513 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast( GetPlugin( PluginRecipesManager ) );
514 return plugin_recipes_manager.GetValidRecipes( ItemBase.Cast( entity1 ), ItemBase.Cast( entity2 ), null, PlayerBase.Cast( GetGame().GetPlayer() ) );
515 }
516
517 override bool TransferItem()
518 {
519 if (CanTakeToInventory())
520 {
521 LeftArea left_area = LeftArea.Cast( GetParent() );
522 EntityAI item;
523 if (left_area)
524 {
525 if (GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ))
526 {
527 return GetFocusedContainer().TransferItem();
528 }
529 else
530 {
531 item = GetFocusedItem();
532 if( item )
533 {
534 GetGame().GetPlayer().PredictiveTakeEntityToInventory( FindInventoryLocationType.CARGO, item );
535 return true;
536 }
537 }
538 }
539 else
540 {
541 if (!GetFocusedContainer().IsInherited( ContainerWithCargo ) && !GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ))
542 {
543 item = GetFocusedItem();
544 if( item )
545 {
546 GetGame().GetPlayer().PredictiveTakeEntityToInventory( FindInventoryLocationType.CARGO, item );
547 return true;
548 }
549 }
550 }
551 }
552 return false;
553 }
554
556 {
557 return GetFocusedContainer().GetFocusedItem();
558 }
559
560 override bool Combine()
561 {
562 if (CanCombine())
563 {
564 if ( GetFocusedContainer() && ( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) ) )
565 {
566 return GetFocusedContainer().Combine();
567 }
568 else
569 {
570 EntityAI item = GetFocusedItem();
571 ItemBase item_in_hands = ItemBase.Cast( GetGame().GetPlayer().GetHumanInventory().GetEntityInHands() );
572
574
575 if( item_in_hands && item )
576 {
577 return hands_icon.CombineItems( item_in_hands, item );
578 }
579 }
580 }
581 return true;
582 }
583
584 override bool Select()
585 {
586 if( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
587 {
588 return GetFocusedContainer().Select();
589 }
590 else
591 {
592 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
594 SlotsIcon focused_slot = GetFocusedSlotsIcon();
595 EntityAI focused_item = focused_slot.GetEntity();
596 if( focused_slot.IsReserved() || focused_item != selected_item )
597 {
598 if( selected_item )
599 {
600 if( selected_item.GetInventory().CanRemoveEntity() )
601 {
602 if (m_Player.GetInventory().CanAddAttachmentEx( selected_item, focused_slot.GetSlotID() ))
603 {
604 player.PredictiveTakeEntityToTargetAttachmentEx( m_Player, selected_item, focused_slot.GetSlotID());
605 //m_Player.PredictiveTakeEntityAsAttachmentEx( selected_item, focused_slot.GetSlotID() );
606 ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
607 return true;
608
609 }
610 else if (m_Player.GetInventory().CanAddAttachment( selected_item ))
611 {
612 player.PredictiveTakeEntityToTargetAttachment( m_Player, selected_item );
613 //m_Player.PredictiveTakeEntityToInventory( FindInventoryLocationType.ATTACHMENT, selected_item );
614 ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
615 return true;
616 }
617 }
618 }
619 else
620 {
621 if( focused_item && focused_item.GetInventory().CanRemoveEntity() )
622 {
623 EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
624 if( item_in_hands && item_in_hands.GetInventory().CanRemoveEntity() )
625 {
626 if( GameInventory.CanSwapEntitiesEx( item_in_hands, focused_item ) )
627 {
628 player.PredictiveSwapEntities( item_in_hands, focused_item );
629 return true;
630 }
631 else
632 {
633 InventoryLocation il_hands_dst = new InventoryLocation;
634 if( player.GetHumanInventory().FindFreeLocationFor( item_in_hands, FindInventoryLocationType.ANY, il_hands_dst ) )
635 {
636 InventoryMode invMode = InventoryMode.PREDICTIVE;
637
638 if ( player.NeedInventoryJunctureFromServer(item_in_hands, item_in_hands.GetHierarchyParent(), il_hands_dst.GetParent()) || GetGame().GetPlayer().NeedInventoryJunctureFromServer(focused_item, focused_item.GetHierarchyParent(), GetGame().GetPlayer()) )
639 invMode = InventoryMode.JUNCTURE;
640
641 player.GetHumanInventory().ForceSwapEntities( invMode, focused_item, item_in_hands, il_hands_dst );
642 return true;
643 }
644 }
645 }
646 else
647 {
648 if( player.GetHumanInventory().CanAddEntityInHands( focused_item ) )
649 {
650 player.PredictiveTakeEntityToHands( focused_item );
651 return true;
652 }
653 }
654 }
655 }
656 }
657 }
658 return false;
659 }
660
662 {
663 if (m_Player)
664 {
665 m_Player.GetOnItemAttached().Remove(ItemAttached);
666 m_Player.GetOnItemDetached().Remove(ItemDetached);
667 m_Player.GetOnAttachmentSetLock().Remove(OnAttachmentReservationSet);
668 m_Player.GetOnAttachmentReleaseLock().Remove(OnAttachmentReservationRelease);
669 }
670
671 m_Player = player;
672 if (m_Player)
673 {
674 m_Player.GetOnItemAttached().Insert(ItemAttached);
675 m_Player.GetOnItemDetached().Insert(ItemDetached);
676 m_Player.GetOnAttachmentSetLock().Insert(OnAttachmentReservationSet);
677 m_Player.GetOnAttachmentReleaseLock().Insert(OnAttachmentReservationRelease);
678 }
679
680 //START - InitGhostSlots
681 string config_path_ghosts_slots = "CfgVehicles SurvivorBase InventoryEquipment playerSlots";
682 ref array<string> player_ghosts_slots = new array<string>;
683 GetGame().ConfigGetTextArray( config_path_ghosts_slots, player_ghosts_slots );
684
685 for ( int i = 0; i < player_ghosts_slots.Count(); i++ )
686 {
687 string slot_name = player_ghosts_slots.Get ( i );
688
689 int column = i % ITEMS_IN_ROW;
690 int row = i / ITEMS_IN_ROW;
691
692 SlotsIcon icon = GetSlotsIcon( row, column );
693
695 icon.GetMainWidget().Show( true );
696 icon.Clear();
697
698 GetGame().ConfigGetText( "CfgSlots" + " " + slot_name + " name", slot_name );
699 EntityAI item = m_Player.GetInventory().FindAttachment( InventorySlots.GetSlotIdFromString( slot_name ) );
700 if( item )
701 {
702 ItemAttached( item, slot_name );
703 }
704 }
705 }
706
707 override void OnDropReceivedFromHeader( Widget w, int x, int y, Widget receiver )
708 {
710
711 if( !ipw.IsInherited( ItemPreviewWidget ) )
712 {
713 return;
714 }
715
716 EntityAI item = ipw.GetItem();
717 if( !item )
718 {
719 return;
720 }
721
722 if( !item.GetInventory().CanRemoveEntity() )
723 return;
724
725 if( m_Player.GetInventory().CanAddEntityToInventory( item, FindInventoryLocationType.CARGO | FindInventoryLocationType.ATTACHMENT ) && ( !m_Player.GetInventory().HasEntityInInventory( item ) ) )
726 {
727 m_Player.PredictiveTakeEntityToInventory( FindInventoryLocationType.CARGO | FindInventoryLocationType.ATTACHMENT, item );
728 }
729 }
730
732 {
733 ItemPreviewWidget ipw = ItemPreviewWidget.Cast( w.FindAnyWidget("Render") );
734 if( !ipw )
735 {
736 string name = w.GetName();
737 name.Replace( "PanelWidget", "Render" );
738 ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
739 }
740 if( !ipw )
741 {
742 ipw = ItemPreviewWidget.Cast( w );
743 }
744
745 return ipw;
746 }
747
748 override void DraggingOverHeader( Widget w, int x, int y, Widget receiver )
749 {
750 if( w == null )
751 {
752 return;
753 }
755
756 if( !ipw || !ipw.IsInherited( ItemPreviewWidget ) )
757 {
758 return;
759 }
760
761 EntityAI item = ipw.GetItem();
762 if( !item )
763 {
764 return;
765 }
766
767 if( m_Player.GetInventory().CanAddEntityToInventory( item, FindInventoryLocationType.CARGO | FindInventoryLocationType.ATTACHMENT ) && !m_Player.GetInventory().HasEntityInInventory( item ) )
768 {
770 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
772 }
773 else
774 {
776 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
778 //ItemManager.GetInstance().ShowSourceDropzone( item );
779 }
780 }
781
782 override void DraggingOver( Widget w, int x, int y, Widget receiver )
783 {
784 if( w == null )
785 {
786 return;
787 }
788
789 EntityAI receiver_item;
790 bool is_reserved = false;
791
792 SlotsIcon slots_icon;
793 receiver.GetUserData(slots_icon);
794
795 if(slots_icon)
796 {
797 receiver_item = slots_icon.GetEntity();
798 is_reserved = slots_icon.IsReserved();
799 }
800
802
803 if( !ipw || !ipw.IsInherited( ItemPreviewWidget ) )
804 {
805 return;
806 }
807
808 EntityAI item = ipw.GetItem();
809 if( !item )
810 {
811 return;
812 }
813
814 if( receiver_item && !is_reserved )
815 {
816 if( GameInventory.CanSwapEntitiesEx( receiver_item, item ) )
817 {
820 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
821 return;
822 }
823 else if( receiver_item.GetInventory().CanAddAttachment(item) || receiver_item.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && !receiver_item.GetInventory().HasEntityInCargo( item ))
824 {
827 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
828 return;
829 }
830 else if( ( ItemBase.Cast( receiver_item ) ).CanBeCombined( ItemBase.Cast( item ) ) )
831 {
834 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
835 return;
836 }
837
838 }
839
840 if( item.GetInventory().CanRemoveEntity() )
841 {
842 if( m_Player.GetInventory().CanAddAttachment( item) )
843 {
846 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
847 }
848 else if( m_Player.GetInventory().CanAddEntityToInventory( item, FindInventoryLocationType.CARGO | FindInventoryLocationType.ATTACHMENT ) && ( !m_Player.GetInventory().HasEntityInInventory( item ) ) || m_Player.GetHumanInventory().HasEntityInHands( item ) )
849 {
852 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
853 }
854 else if ( receiver_item && GameInventory.CanSwapEntitiesEx( receiver_item, item ) )
855 {
858 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
859 }
860 else
861 {
864 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
865 }
866 }
867 else
868 {
871 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
872 //ItemManager.GetInstance().ShowSourceDropzone( item );
873 }
874 }
875
876 void OnDropReceivedFromGhostArea( Widget w, int x, int y, Widget receiver )
877 {
880
881 EntityAI receiver_item;
882 bool is_reserved = false;
883 InventoryMenu menu = InventoryMenu.Cast( GetGame().GetUIManager().FindMenu( MENU_INVENTORY ) );
884 float stack_max;
885
887 SlotsIcon slots_icon;
888 receiver.GetUserData(slots_icon);
889 int slot_id = slots_icon.GetSlotID();
890
891 receiver_item = slots_icon.GetEntity();
892 is_reserved = slots_icon.IsReserved();
894
895 if ( !ipw )
896 {
897 return;
898 }
899
900 ItemBase item = ItemBase.Cast(ipw.GetItem());
901 PlayerBase real_player = PlayerBase.Cast( GetGame().GetPlayer() );
902 if ( !item )
903 {
904 return;
905 }
906 if ( receiver_item && !is_reserved )
907 {
908 if ( GameInventory.CanSwapEntitiesEx( receiver_item, item ) )
909 {
910 GetGame().GetPlayer().PredictiveSwapEntities( item, receiver_item );
911
912 if ( menu )
913 {
914 menu.RefreshQuickbar();
915 }
916 return;
917 }
918 else if ( receiver_item.GetInventory().CanAddAttachment( item ) )
919 {
920 GetGame().GetPlayer().PredictiveTakeEntityToTargetAttachment( receiver_item, item );
921
922 if ( menu )
923 {
924 menu.RefreshQuickbar();
925 }
926 return;
927 }
928 else if ( receiver_item.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && !receiver_item.GetInventory().HasEntityInCargo( item ) )
929 {
930 SplitItemUtils.TakeOrSplitToInventory(real_player, receiver_item,item);
931
932 if ( menu )
933 {
934 menu.RefreshQuickbar();
935 }
936 return;
937 }
938 else if ( ( ItemBase.Cast( receiver_item ) ).CanBeCombined( ItemBase.Cast( item ) ) )
939 {
940 ( ItemBase.Cast( receiver_item ) ).CombineItemsClient( ItemBase.Cast( item ) );
941 return;
942 }
943 }
944
945 if ( m_Player.GetInventory().CanAddAttachmentEx( item, slot_id ) )
946 {
947 if (item.GetQuantity() > item.GetTargetQuantityMax(slot_id))
948 {
949 item.SplitIntoStackMaxClient( real_player, slot_id );
950 }
951 else
952 {
953 real_player.PredictiveTakeEntityToTargetAttachmentEx( m_Player, item, slots_icon.GetSlotID() );
954 }
955 }
956 else if ( m_Player.GetInventory().CanAddAttachment( item ) )
957 {
958 il = new InventoryLocation;
959 m_Player.GetInventory().FindFreeLocationFor( item, FindInventoryLocationType.ATTACHMENT, il );
960 float stackable = item.GetTargetQuantityMax(-1);
961
962 if( il.IsValid() )
963 {
964 if ( stackable == 0 || stackable >= item.GetQuantity() )
965 {
966 real_player.PredictiveTakeEntityToTargetAttachment( il.GetParent(), item );
967 }
968 else
969 {
970
971 ItemBase.Cast(item).SplitIntoStackMaxToInventoryLocationClient( il );
972 }
973 }
974 }
975 else if( m_Player.GetInventory().CanAddEntityToInventory( item, FindInventoryLocationType.CARGO | FindInventoryLocationType.ATTACHMENT ) && ( !m_Player.GetInventory().HasEntityInInventory( item ) ) || m_Player.GetHumanInventory().HasEntityInHands( item ) )
976 {
978 }
979
980 if ( menu )
981 {
982 menu.RefreshQuickbar();
983 }
984 }
985
986 void SwapItemsInOrder( int slot1, int slot2 )
987 {
988 EntityAI item1 = m_Player.GetInventory().FindAttachment( slot1 );
989 EntityAI item2 = m_Player.GetInventory().FindAttachment( slot2 );
990
991 if( item1 && item2 )
992 {
993 Container cont1 = m_ShowedItems.Get( item1 );
994 Container cont2 = m_ShowedItems.Get( item2 );
995 if( cont1 && cont2 )
996 {
997 int sort1 = cont1.GetRootWidget().GetSort();
998 int sort2 = cont2.GetRootWidget().GetSort();
999
1000 cont1.GetRootWidget().SetSort( sort2 );
1001 cont2.GetRootWidget().SetSort( sort1 );
1002
1003 m_Body.SwapItems( m_Body.Find( cont1 ), m_Body.Find( cont2 ) );
1004 }
1005 }
1006 RecomputeOpenedContainers();
1007 }
1008
1009 override void UpdateInterval()
1010 {
1011 int i;
1012 for ( i = 0; i < m_InventorySlots.Count(); i++ )
1013 {
1014 SlotsIcon icon = m_InventorySlots.GetElement( i );
1015 if ( icon )
1016 {
1017 icon.UpdateInterval();
1018 }
1019 }
1020 for ( i = 0; i < m_ShowedItems.Count(); i++ )
1021 {
1022 Container cont = m_ShowedItems.GetElement( i );
1023 if ( cont )
1024 {
1025 cont.UpdateInterval();
1026 }
1027 }
1028 }
1029
1030 // Call from ToggleWidget
1032 {
1034 item.GetInventory().GetCurrentInventoryLocation( il );
1035 SlotsIcon icon = m_InventorySlots.Get( il.GetSlot() );
1036 ClosableContainer c = ClosableContainer.Cast( m_ShowedItems.Get( item ) );
1037 if (c)
1038 {
1039 c.Toggle();
1040 Refresh();
1041 }
1042 }
1043
1044 override bool CanOpenCloseContainerEx(EntityAI focusedEntity)
1045 {
1046 if (focusedEntity)
1047 {
1048 ClosableContainer c = ClosableContainer.Cast( m_ShowedItems.Get( focusedEntity ) );
1049 if (c && c.IsDisplayable())
1050 {
1051 return true;
1052 }
1053 }
1054 return false;
1055 }
1056
1057 // Mouse button UP or Call other fn
1059 {
1061 {
1062 return;
1063 }
1064 string name = w.GetName();
1065 name.Replace( "PanelWidget", "Render" );
1066 ItemPreviewWidget ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
1067 if( ipw.GetItem() )
1068 {
1069 ToggleContainer( w, ipw.GetItem() );
1070 RecomputeOpenedContainers();
1071 }
1072
1073 Refresh();
1074 }
1075
1077 {
1078 super.CollapseButtonOnMouseButtonDown(w);
1079 }
1080
1082 {
1083 if( GetFocusedContainer() && ( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) ) )
1084 {
1085 return false;
1086 }
1087
1088 return true;
1089 }
1090
1091 override void Refresh()
1092 {
1093 super.Refresh();
1094 m_MainWidget.Update();
1095 m_RootWidget.Update();
1096 UpdateSelectionIcons();
1097 }
1098
1099 override bool OnChildRemove( Widget w, Widget child )
1100 {
1101 Refresh();
1102 return true;
1103 }
1104
1105 override bool OnChildAdd( Widget w, Widget child )
1106 {
1107 Refresh();
1108 return true;
1109 }
1110}
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Определения Inventory.c:22
const int ITEMS_IN_ROW
Определения Attachments.c:1
void Inventory(LayoutHolder parent)
Определения Inventory.c:74
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
void InventoryMenu()
Определения InventoryMenu.c:20
PlayerBase GetPlayer()
Определения ModifierBase.c:51
string path
Определения OptionSelectorMultistate.c:142
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
Определения PluginRemotePlayerDebugClient.c:14
proto native bool ConfigIsExisting(string path)
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()
override bool IsOpened()
Определения ContainerWithCargo.c:102
override bool IsDisplayable()
Определения ContainerWithCargo.c:19
void CollapsibleContainer(LayoutHolder parent, int sort=-1)
Определения CollapsibleContainer.c:6
ref CollapsibleHeader m_CollapsibleHeader
Определения CollapsibleContainer.c:3
bool IsHidden()
Определения CollapsibleContainer.c:126
override Header GetHeader()
Определения CollapsibleContainer.c:176
override void SetHeader(Header header)
Определения CollapsibleContainer.c:181
void SetColor(Widget w, int color)
Определения ColorManager.c:32
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
void ClosableContainer(LayoutHolder parent, int sort=-1)
Определения ClosableContainer.c:6
override void UpdateInterval()
Определения CargoContainer.c:543
Определения 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
Icon GetIcon()
Определения HandsPreview.c:35
bool CombineItems(EntityAI entity1, EntityAI entity2)
Определения Icon.c:731
Определения Icon.c:2
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
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
provides access to slot configuration
Определения InventorySlots.c:6
Определения InventoryItem.c:731
void SetSelectedItemEx(EntityAI selected_item, Container selected_container, LayoutHolder selected_icon)
Определения ItemManager.c:113
HandsPreview GetHandsPreview()
Определения ItemManager.c:75
EntityAI GetSelectedItem()
Определения ItemManager.c:85
Widget GetRightDropzone()
Определения ItemManager.c:344
void HideDropzones()
Определения ItemManager.c:287
bool IsDragging()
Определения ItemManager.c:393
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
Определения LeftArea.c:2
Определения PlayerBaseClient.c:2
override void ExpandCollapseContainer()
Определения PlayerContainer.c:449
void OnAttachmentReservationRelease(EntityAI item, int slot_id)
Определения PlayerContainer.c:224
override bool IsItemWithQuantityActive()
Определения PlayerContainer.c:354
override void UpdateRadialIcon()
Определения PlayerContainer.c:11
const int HEADER_INDEX_OFFSET
Определения PlayerContainer.c:9
override bool OnChildRemove(Widget w, Widget child)
Определения PlayerContainer.c:1099
override void Refresh()
Определения PlayerContainer.c:1091
override bool OnChildAdd(Widget w, Widget child)
Определения PlayerContainer.c:1105
float GetMainContainerTopPos()
Определения PlayerContainer.c:300
override void DraggingOver(Widget w, int x, int y, Widget receiver)
Определения PlayerContainer.c:782
override bool InspectItem()
Определения PlayerContainer.c:492
override bool Select()
Определения PlayerContainer.c:584
override void CollapseButtonOnMouseButtonDown(Widget w)
Определения PlayerContainer.c:1076
bool IsPlayerEquipmentActive()
Определения PlayerContainer.c:1081
void ItemAttached(EntityAI item, string slot_name)
Определения PlayerContainer.c:124
bool IsEmptyItemActive()
Определения PlayerContainer.c:366
SlotsIcon GetSlotsIcon(int row, int column)
Определения PlayerContainer.c:29
override void Insert(LayoutHolder container, int pos=-1, bool immedUpdate=true)
Определения PlayerContainer.c:317
void SetPlayer(PlayerBase player)
Определения PlayerContainer.c:661
ref map< int, ref Container > m_ShowedItemsIDs
Определения PlayerContainer.c:6
override EntityAI GetFocusedItem()
Определения PlayerContainer.c:555
void ToggleWidget(Widget w)
Определения PlayerContainer.c:1058
override bool TransferItem()
Определения PlayerContainer.c:517
void OnAttachmentReservationSet(EntityAI item, int slot_id)
Определения PlayerContainer.c:214
PlayerBase m_Player
Определения PlayerContainer.c:7
override bool Combine()
Определения PlayerContainer.c:560
bool HasEntityContainerVisible(EntityAI entity)
Определения PlayerContainer.c:23
float GetMainContainerBottomPos()
Определения PlayerContainer.c:307
bool IsItemWithContainerActive()
Определения PlayerContainer.c:348
override void UpdateInterval()
Определения PlayerContainer.c:1009
void UnfocusPlayerAttachmentsContainer()
Определения PlayerContainer.c:372
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
Определения PlayerContainer.c:748
override bool TransferItemToVicinity()
Определения PlayerContainer.c:467
int GetRecipeCount(bool recipe_anywhere, EntityAI entity1, EntityAI entity2)
Определения PlayerContainer.c:511
bool IsContainerWithCargoActive()
Определения PlayerContainer.c:457
override bool CanOpenCloseContainerEx(EntityAI focusedEntity)
Определения PlayerContainer.c:1044
ref AttachmentsGroupContainer m_PlayerAttachmentsContainer
Определения PlayerContainer.c:3
void ~PlayerContainer()
Определения PlayerContainer.c:113
void MouseClick(Widget w, int x, int y, int button)
Определения PlayerContainer.c:237
bool IsItemWithAttachmentsActive()
Определения PlayerContainer.c:462
void AddSlotsContainer(int row_count)
Определения PlayerContainer.c:230
void ToggleContainer(Widget w, EntityAI item)
Определения PlayerContainer.c:1031
void ItemDetached(EntityAI item, string slot_name)
Определения PlayerContainer.c:189
void SwapItemsInOrder(int slot1, int slot2)
Определения PlayerContainer.c:986
void PlayerContainer(LayoutHolder parent, int sort=-1)
Определения PlayerContainer.c:34
void OnDropReceivedFromGhostArea(Widget w, int x, int y, Widget receiver)
Определения PlayerContainer.c:876
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
Определения PlayerContainer.c:707
ItemPreviewWidget GetItemPreviewWidget(Widget w)
Определения PlayerContainer.c:731
override bool IsItemActive()
Определения PlayerContainer.c:360
void DoubleClick(Widget w, int x, int y, int button)
Определения PlayerContainer.c:377
ref map< int, SlotsIcon > m_InventorySlots
Определения PlayerContainer.c:4
ref map< EntityAI, ref Container > m_ShowedItems
Определения PlayerContainer.c:5
static int HasItemQuantity(notnull EntityAI item)
Определения QuantityConversions.c:143
Widget GetSlotsArea()
Определения RightArea.c:254
Определения RightArea.c:2
Определения SlotsContainer.c:2
Widget GetPanelWidget()
Определения SlotsIcon.c:205
EntityAI GetEntity()
Определения SlotsIcon.c:365
void Init(EntityAI obj, bool reservation=false)
Определения SlotsIcon.c:501
void SetSlotID(int slot_ID)
Определения SlotsIcon.c:195
void SetSlotDisplayName(string text)
Определения SlotsIcon.c:144
bool IsReserved()
Определения SlotsIcon.c:200
void SetSlotParent(EntityAI parent)
Определения SlotsIcon.c:134
int GetSlotID()
Определения SlotsIcon.c:190
void Clear()
Определения SlotsIcon.c:612
override void UpdateInterval()
Определения SlotsIcon.c:791
Widget GetRadialIconPanel()
Определения SlotsIcon.c:300
ImageWidget GetGhostSlot()
Определения SlotsIcon.c:235
Определения SlotsIcon.c:2
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
void RegisterOnDropReceived(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:91
void RegisterOnDraggingOver(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:112
void RegisterOnChildRemove(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:167
static WidgetEventHandler GetInstance()
Определения WidgetEventHandler.c:22
void RegisterOnMouseButtonDown(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:70
void RegisterOnMouseButtonUp(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:77
void RegisterOnChildAdd(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:160
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()
const int MENU_INVENTORY
Определения constants.c:180
MouseState
Определения EnSystem.c:311
proto native Widget GetParent()
Get parent of the Effect.
Определения Effect.c:407