27 GetMainWidget().SetFlags(
WidgetFlags.IGNOREPOINTER );
28 m_MainWidget = m_MainWidget.FindWidget(
"body" );
29 GetMainWidget().SetFlags(
WidgetFlags.IGNOREPOINTER );
40 RecomputeOpenedContainers();
69 return m_ActiveIndex == m_OpenedContainers.Count() - 1;
74 int index = m_ActiveIndex - 1;
75 int attachment_start_index = -1;
76 int cargo_start_index = -1;
77 int attachment_end_index = -1;
78 int cargo_end_index = -1;
82 attachment_start_index = 0;
84 attachment_end_index++;
90 cargo_start_index = attachment_end_index + 1;
96 if ( m_ActiveIndex > m_OpenedContainers.Count() )
98 m_ActiveIndex = m_OpenedContainers.Count();
103 #ifdef PLATFORM_CONSOLE
104 if ( m_MainWidget.FindAnyWidget(
"Selected") )
105 m_MainWidget.FindAnyWidget(
"Selected").Show(
true );
111 if( index.InRange( 0, attachment_end_index ) )
132 else if( index.InRange( cargo_start_index, cargo_end_index ) )
136 if( index == cargo_start_index )
144 SetFocusedContainer(
m_AttachmentCargos.GetElement( index - 1 - cargo_start_index ) );
154 if( m_MainWidget.FindAnyWidget(
"Selected") )
155 m_MainWidget.FindAnyWidget(
"Selected").Show(
false );
162 if( !active_container )
170 if( next_pos > (
y + y_s ) )
184 super.Insert( container, pos, immedUpdate );
189 string name = w.GetName();
217 if(m_ActiveIndex == 0)
220 if( item_in_hands &&
GetGame().
GetPlayer().GetHumanInventory().CanRemoveEntityInHands() && !
GetGame().
GetPlayer().GetInventory().HasInventoryReservation(item_in_hands, null) )
224 m_MainWidget.FindAnyWidget(
"Selected").Show(
false );
225 m_MainWidget.FindAnyWidget(
"hands_preview_root").SetAlpha( 0.7 );
230 else if( GetFocusedContainer() )
232 return GetFocusedContainer().TransferItem();
239 if (m_ActiveIndex == 0)
244 if ( item_in_hands.CanBeSplit() )
246 item_in_hands.OnRightClick();
250 else if( GetFocusedContainer() )
252 return GetFocusedContainer().SplitItem();
259 if (m_ActiveIndex == 0)
264 if (
GetGame().
GetPlayer().GetHumanInventory().CanRemoveEntityInHands() && !
GetGame().
GetPlayer().GetInventory().HasInventoryReservation(item_in_hands, null) )
268 m_MainWidget.FindAnyWidget(
"Selected").Show(
false );
269 m_MainWidget.FindAnyWidget(
"hands_preview_root").SetAlpha( 0.7 );
275 else if( GetFocusedContainer() )
277 return GetFocusedContainer().EquipItem();
284 super.SetActive(active);
286 EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
290 if( m_MainWidget.FindAnyWidget(
"Selected" ) )
292 m_MainWidget.FindAnyWidget(
"Selected" ).Show( active );
298 GetMainWidget().GetScreenPos(
x,
y );
299 PrepareOwnedTooltip( item_in_hands, -1,
y );
305 m_MainWidget.FindAnyWidget(
"hands_preview_root" ).SetAlpha( 0.85 );
307 m_MainWidget.FindAnyWidget(
"hands_preview_root" ).SetAlpha( 0.7 );
313 super.SetLastActive();
315 EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
319 if ( m_ActiveIndex == 0)
321 if( m_MainWidget.FindAnyWidget(
"Selected" ) )
323 m_MainWidget.FindAnyWidget(
"Selected" ).Show(
true );
327 GetMainWidget().GetScreenPos(
x,
y );
328 PrepareOwnedTooltip( item_in_hands,
x,
y );
333 m_MainWidget.FindAnyWidget(
"hands_preview_root" ).SetAlpha( 0.85 );
346 ItemBase item =
ItemBase.Cast( player.GetHumanInventory().GetEntityInHands() );
357 ItemBase item =
ItemBase.Cast( player.GetHumanInventory().GetEntityInHands() );
368 return player.GetHumanInventory().GetEntityInHands() == null;
373 if (m_ActiveIndex == 0)
376 ItemBase item_in_hands =
ItemBase.Cast(player.GetHumanInventory().GetEntityInHands());
377 if ( item_in_hands && player.CanDropEntity( item_in_hands ) &&
GetGame().
GetPlayer().GetHumanInventory().CanRemoveEntityInHands() && !player.GetInventory().HasInventoryReservation(item_in_hands, null) )
379 if ( item_in_hands.GetTargetQuantityMax() < item_in_hands.GetQuantity() )
380 item_in_hands.SplitIntoStackMaxClient( null, -1 );
382 player.PhysicalPredictiveDropItem( item_in_hands );
383 m_MainWidget.FindAnyWidget(
"Selected").Show(
false );
384 m_MainWidget.FindAnyWidget(
"hands_preview_root").SetAlpha( 0.7 );
388 else if ( GetFocusedContainer() )
390 return GetFocusedContainer().TransferItemToVicinity();
397 if(m_ActiveIndex == 0)
400 EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
407 else if( GetFocusedContainer() )
409 return GetFocusedContainer().InspectItem();
416 if(m_ActiveIndex == 0)
423 Inventory.GetInstance().DisableMicromanagement();
433 Inventory.GetInstance().EnableMicromanagement();
439 if( GetFocusedContainer() )
441 return GetFocusedContainer().OnSelectButton();
452 string name = w.GetName();
480 string name = w.GetName();
494 receiver.GetUserData(slots_icon);
512 if( receiver_entity )
518 if( receiver_itemIB && itemIB && receiver_itemIB.
CanBeCombined( itemIB ) )
534 Magazine mag = Magazine.Cast(receiver_item);
539 if( player.GetWeaponManager().CanSwapMagazine( wpn, Magazine.Cast(w_entity) ) )
542 if( w_entity.GetHierarchyRootPlayer() == player )
572 else if( receiver_itemIB.GetInventory().CanAddAttachment( w_entity ) )
588 else if( slot_owner && slot_owner.GetInventory().CanAddAttachment( w_entity ) )
594 else if( receiver_entity.GetInventory().CanAddAttachment( w_entity ) )
638 if ( m_am_entity1 == null || m_am_entity2 == null )
return;
659 if( m_am_entity2.GetSlotsCountCorrect() > 0 )
686 m_player.PredictiveTakeEntityToTargetCargo( m_am_entity1, m_am_entity2 );
707 if ( !
m_player.PredictiveSwapEntities( m_am_entity1, m_am_entity2 ) &&
m_player.GetHumanInventory().CanAddEntityInHands( m_am_entity1 ) )
709 m_player.PredictiveTakeEntityToHands( m_am_entity1 );
721 if ( m_am_entity2.GetSlotsCountCorrect() > 0 )
730 if (
m_player.GetHumanInventory().CanAddEntityInHands( m_am_entity2 ) )
732 m_player.PredictiveTakeEntityToHands( m_am_entity2 );
739 if ( entity1 && entity2 )
PrintString(
"Showing action menu for " + entity1.GetDisplayName() +
" and " + entity2.GetDisplayName() );
742 m_am_entity1 = entity1;
743 m_am_entity2 = entity2;
750 entity.CombineItemsClient(
ItemBase.Cast( entity2 ) );
754 if ( entity1 == null || entity2 == null )
return;
787 int m_am_pos_x, m_am_pos_y;
792 cmenu.Show( m_am_pos_x, m_am_pos_y );
807 if ( !entity1 || !entity2 )
return flags;
811 bool skipSwap =
false;
817 if(
Class.
CastTo(parentWpn, swapmag1.GetHierarchyParent()) )
824 if(
Class.
CastTo(parentWpn, swapmag2.GetHierarchyParent()) )
838 if ( !entity1.IsInherited(
ZombieBase ) && !entity1.IsInherited( Car ) )
851 else if ( entity1.GetInventory().CanAddAttachment( entity2 ) )
853 if ( !entity1.IsInherited(
ZombieBase ) && !entity1.IsInherited( Car ) && !entity2.IsInherited(
ZombieBase ) && !entity2.IsInherited( Car ) )
860 if( entity1 ==
m_player.GetHumanInventory().GetEntityInHands() || entity2 ==
m_player.GetHumanInventory().GetEntityInHands() )
864 if( entity1 ==
m_player.GetHumanInventory().GetEntityInHands() )
889 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(
GetPlugin( PluginRecipesManager ) );
917 m_Body.RemoveItem( att );
926 RecomputeOpenedContainers();
976 m_Body.RemoveItem( cargo );
984 RecomputeOpenedContainers();
990 EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
1007 target_cargo =
m_Entity.GetInventory().GetCargo();
1008 #ifdef PLATFORM_CONSOLE
1020 target_cargo = target_entity.GetInventory().GetCargo();
1021 #ifdef PLATFORM_CONSOLE
1022 if( cargo.HasItem( item ) )
1032 if( target_cargo && target_entity )
1041 #ifdef PLATFORM_CONSOLE
1046 dst.
SetCargoAuto(target_cargo, item,
x,
y, item.GetInventory().GetFlipCargo());
1050 item.GetInventory().GetCurrentInventoryLocation(src);
1054 #ifdef PLATFORM_CONSOLE
1055 if(dst.
IsValid() && target_entity.GetInventory().LocationCanAddEntity(dst))
1057 if( c_x >
x && c_y >
y && target_entity.GetInventory().LocationCanAddEntity(dst))
1062 Icon icon = cargo.GetIcon( item );
1066 if( w && w.FindAnyWidget(
"Selected") )
1084 if( !item || !item_in_hands )
1093 if( item_in_hands.GetInventory().GetCargo() )
1095 c_x = item_in_hands.GetInventory().GetCargo().GetHeight();
1096 c_y = item_in_hands.GetInventory().GetCargo().GetWidth();
1099 if( c_x >
x && c_y >
y && item_in_hands.GetInventory().CanAddEntityInCargoEx( item, 0,
x,
y, item.GetInventory().GetFlipCargo() ) )
1111 if( w.FindAnyWidget(
"Selected") )
1113 w.FindAnyWidget(
"Selected").SetColor( color );
1117 string name = w.GetName();
1119 w.FindAnyWidget(
name ).SetColor( color );
1132 receiver.GetUserData(slots_icon);
1147 float stack_max = item_base.GetTargetQuantityMax(slot_id);
1150 if( !item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory() )
1158 if( player.GetWeaponManager().CanAttachMagazine( wpn, mag ) )
1160 player.GetWeaponManager().AttachMagazine( mag );
1162 else if(player.GetWeaponManager().CanSwapMagazine( wpn, mag ))
1164 player.GetWeaponManager().SwapMagazine( mag );
1167 else if( receiver_item )
1169 if( receiver_item != item )
1171 if( (
ItemBase.Cast( receiver_item ) ).CanBeCombined(
ItemBase.Cast( item ) ) )
1177 if( !receiver_item.GetInventory().CanRemoveEntity() )
1183 else if( slot_owner && slot_owner.GetInventory().CanAddAttachmentEx( item, slot_id ) )
1185 if( stack_max == 0 || stack_max >= item_base.GetQuantity() )
1187 player.PredictiveTakeEntityToTargetAttachmentEx(slot_owner, item, slot_id);
1189 else if( stack_max != 0 && stack_max < item_base.GetQuantity() )
1191 item_base.SplitIntoStackMaxClient(
m_Entity, slot_id );
1194 else if( slot_owner && slot_owner.GetInventory().CanAddAttachment( item ) )
1196 if( stack_max == 0 || stack_max >= item_base.GetQuantity() )
1198 player.PredictiveTakeEntityToTargetAttachment(slot_owner, item);
1200 else if( stack_max != 0 && stack_max < item_base.GetQuantity() )
1202 item_base.SplitIntoStackMaxClient(
m_Entity, -1 );
1205 else if(
m_Entity.GetInventory().CanAddAttachment( item ) )
1207 if( stack_max == 0 || stack_max >= item_base.GetQuantity() )
1209 player.PredictiveTakeEntityToTargetAttachment(
m_Entity, item);
1211 else if( stack_max != 0 && stack_max < item_base.GetQuantity() )
1213 item_base.SplitIntoStackMaxClient(
m_Entity, -1 );
1216 else if( (
m_Entity.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && ( !player.GetInventory().HasEntityInInventory( item ) || !
m_Entity.GetInventory().HasEntityInCargo( item )) ) || player.GetHumanInventory().HasEntityInHands( item ) )
1235 if( entity.GetSlotsCountCorrect() > 0 )
1249 if( entity.GetInventory().GetCargo() )
1270 bool hideCargo =
m_Entity.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) || !
m_Entity.CanDisplayCargo() || m_ForcedHide;
1282 RecomputeOpenedContainers();
1289 for (
int i = 0; i < m_Body.Count(); i++)
1291 m_Body.Get( i ).OnShow();
1304 if( item.GetInventory().GetAttachmentSlotsCount() > 0 )
1316 Inventory.GetInstance().UpdateConsoleToolbar();
1319 if( item.GetInventory().GetCargo() )
1323 cont.GetRootWidget().SetSort( sort );
1324 cont.SetEntity( item );
1331 Inventory.GetInstance().UpdateConsoleToolbar();
1339 cont.ShowFalseCargoHeader(
false);
1346 cont.SetAlternateFalseTextHeaderWidget(null);
1349 RecomputeOpenedContainers();
1359 m_Body.RemoveItem( old_cont );
1364 Inventory.GetInstance().UpdateConsoleToolbar();
1372 m_Body.RemoveItem( old_att_cont );
1373 delete old_att_cont;
1376 Inventory.GetInstance().UpdateConsoleToolbar();
1378 RecomputeOpenedContainers();
1383 super.UpdateInterval();
1389 bool hideCargo =
m_Entity.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) || !
m_Entity.CanDisplayCargo() || m_ForcedHide;
1426 for (
int i = 0; i < m_Body.Count(); i++ )
1428 m_Body.Get( i ).OnShow();
1443 string name = w.GetName();
1459 EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
1467 if( !item.GetInventory().CanRemoveEntity() )
1470 if( player.GetInventory().HasEntityInInventory( item ) && player.GetHumanInventory().CanAddEntityInHands( item ) )
1472 player.PredictiveTakeEntityToHands( item );
1476 if( player.GetInventory().CanAddEntityToInventory( item ) && player.GetHumanInventory().CanRemoveEntityInHands() )
1482 if( player.GetHumanInventory().CanAddEntityInHands( item ) )
1484 player.PredictiveTakeEntityToHands( item );
1493 w.FindAnyWidget(
name ).Show(
false );
1500 if( item_in_hands && item_in_hands.GetCompEM() )
1504 bool show_electricity_icon = item_in_hands.GetCompEM().HasElectricityIcon();
1505 GetRootWidget().FindAnyWidget(
"electricity" ).Show( show_electricity_icon );
1508 if( GetRootWidget().
FindAnyWidget(
"electricity_can_work" ) )
1510 bool show_electricity_can_work_icon = item_in_hands.GetCompEM().CanWork() && !item_in_hands.IsRuined();
1511 GetRootWidget().FindAnyWidget(
"electricity_can_work" ).Show( show_electricity_can_work_icon );
1516 GetRootWidget().FindAnyWidget(
"electricity" ).Show(
false );
1525 for (i = 0; i < m_Body.Count(); i++)
1527 m_Body.Get( i ).OnHide();
1533 for (i = 0; i < m_Body.Count(); i++)
1535 m_Body.Get( i ).OnShow();
1540 w.FindAnyWidget(
"opened").Show(
m_Hidden);
1541 w.FindAnyWidget(
"closed").Show(!
m_Hidden);
1551 RecomputeOpenedContainers();
1560 RecomputeOpenedContainers();
void Inventory(LayoutHolder parent)
FindInventoryLocationType
flags for searching locations in inventory
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
class PluginItemDiagnosticEventHandler extends ScriptedWidgetEventHandler m_Entity
PluginBase GetPlugin(typename plugin_type)
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
protected Widget m_Parent
bool CanSetActionFromInventory(ItemBase mainItem, ItemBase targetItem)
AttachmentsWrapper GetWrapper()
void SetDefaultFocus(bool while_micromanagment_mode=false)
TextWidget GetFalseHeaderTextWidget()
void InitAttachmentGrid(int att_row_index)
void ShowFalseAttachmentsHeader(bool show)
int GetAttachmentHeight()
array< int > GetSlotsSorted()
proto native DayZPlayer GetPlayer()
represents base for cargo storage for entities
proto native int GetHeight()
proto native int GetItemCount()
proto native int GetWidth()
Super root of all classes in Enforce script.
static ColorManager GetInstance()
void SetColor(Widget w, int color)
void CargoContainer(LayoutHolder parent, bool is_attachment=false)
override float GetFocusedContainerYScreenPos(bool contents=false)
override float GetFocusedContainerHeight(bool contents=false)
override EntityAI GetFocusedItem()
WeaponManager GetWeaponManager()
script counterpart to engine's class Inventory
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
override void UnfocusGrid()
protected ref map< EntityAI, AttachmentsWrapper > m_AttachmentAttachmentsContainers
override void UnfocusAll()
void ScrollToActiveContainer(Container active_container)
protected ref map< EntityAI, ref Attachments > m_AttachmentAttachments
void HandsContainer(LayoutHolder parent)
protected int m_StaticAttCount
protected int m_StaticCargoCount
override bool IsItemActive()
void TakeAsAttachment(Widget w, Widget receiver)
override bool InspectItem()
protected ScrollWidget m_ScrollWidget
void DropReceived(Widget w, int x, int y, CargoContainer cargo)
void ShowActionMenuCombine(EntityAI entity1, EntityAI entity2, int combinationFlags)
override void UpdateInterval()
override bool TransferItem()
void AttachmentAdded(EntityAI item, string slot, EntityAI parent)
protected ref map< EntityAI, ref CargoContainer > m_AttachmentCargos
override bool TransferItemToVicinity()
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
EntityAI GetItemPreviewItem(Widget w)
protected ref HandsHeader m_CollapsibleHeader
protected ref Attachments m_Atts
override void SetActive(bool active)
protected ref HandsPreview m_HandsPreview
void DoubleClick(Widget w, int x, int y, int button)
override bool IsLastIndex()
override Header GetHeader()
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
override bool EquipItem()
void MouseClick2(Widget w, int x, int y, int button)
protected ref CargoContainer m_CargoGrid
override bool IsItemWithQuantityActive()
void AttachmentRemoved(EntityAI item, string slot, EntityAI parent)
protected ref array< int > m_AttachmentSlotsSorted
bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
int GetCombinationFlags(EntityAI entity1, EntityAI entity2)
void OnPerformCombination(int combinationFlags)
override void Insert(LayoutHolder container, int pos=-1, bool immedUpdate=true)
override void SetLastActive()
void DraggingOverHeader2(Widget w, int x, int y, Widget receiver)
override void SetLayoutName()
void OnDropReceivedFromHeader2(Widget w, int x, int y, Widget receiver)
override bool OnSelectButton()
void ShowAtt(EntityAI entity)
override bool SplitItem()
void CollapseButtonOnMouseButtonDown(Widget w)
int GetRecipeCount(bool recipe_anywhere, EntityAI entity1, EntityAI entity2)
override void UpdateInterval()
void ShowCollapseButtons(bool show, bool force=false)
void CreateNewIcon(ItemBase item)
static const int TAKE_TO_HANDS
static const int ADD_AS_CARGO
static const int COMBINE_QUANTITY
static const int ADD_AS_ATTACHMENT
static const int COMBINE_QUANTITY2
static const int SET_ACTION
static const int RECIPE_ANYWHERE
static const int LOAD_CHAMBER
proto native bool IsValid()
verify current set inventory location
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
provides access to slot configuration
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
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Widget GetCenterDropzone()
EntityAI GetSelectedItem()
bool IsMicromanagmentMode()
void ShowSourceDropzone(EntityAI item)
void SetHandsPreview(HandsPreview hansd_preview)
Widget GetRightDropzone()
void SetIsDragging(bool is_dragging)
static ItemManager GetInstance()
static int HasItemQuantity(notnull EntityAI item)
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
bool CanAttachMagazine(Weapon_Base wpn, Magazine mag, bool reservationCheck=true)
bool AttachMagazine(Magazine mag, ActionBase control_action=NULL)
bool CanSwapMagazine(Weapon_Base wpn, Magazine mag, bool reservationCheck=true)
bool LoadBullet(Magazine mag, ActionBase control_action=NULL)
bool SwapMagazine(Magazine mag, ActionBase control_action=NULL)
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.
void PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
proto void GetMousePos(out int x, out int y)
proto int Replace(string sample, string replace)
Replace all occurrances of 'sample' in 'str' by 'replace'.