4 protected const int ROWS_NUMBER_XBOX = 5;
7 protected int m_CargoIndex = -1;
9 protected int m_FocusedItemPosition = -1;
30 m_IsAttachment = is_attachment;
36 m_CargoContainer =
m_RootWidget.FindAnyWidget(
"grid_background" );
37 m_ItemsContainer =
m_RootWidget.FindAnyWidget(
"grid_overlay" );
38 m_CargoHeader =
m_RootWidget.FindAnyWidget(
"grid_container_header_spacer" );
42 m_RootWidget.FindAnyWidget(
"grid_container" ).GetScript( m_Resizer2 );
43 m_CargoHeader.Show( is_attachment );
44 m_FalseHeaderTextWidget =
TextWidget.Cast(m_CargoHeader.FindAnyWidget(
"TextWidget0" ));
47 m_FocusedItemPosition = -1;
67 item.GetInventory().GetCurrentInventoryLocation( il );
71 if ( m_ShowedItemPositions.Contains( item ) )
73 Param3<ref Icon, int, int> item_pos = m_ShowedItemPositions.Get( item );
80 ref
Icon icon =
new Icon(
this,
false );
81 m_Icons.Insert( icon );
83 m_ShowedItemPositions.Insert( item,
new Param3<ref Icon, int, int>( icon,
x,
y ) );
89 #ifdef PLATFORM_CONSOLE
93 Param3<ref Icon, int, int> data = m_ShowedItemPositions.Get( item2 );
96 data.param1.SetCargoPos( i );
101 m_FocusedItemPosition =
Math.
Min( m_ShowedItemPositions.Count() - 1, m_FocusedItemPosition );
115 Param3<ref Icon, int, int> data = m_ShowedItemPositions.Get( item );
118 m_Icons.RemoveItem( data.param1 );
119 m_ShowedItemPositions.Remove( item );
124 #ifdef PLATFORM_CONSOLE
128 data = m_ShowedItemPositions.Get( item2 );
129 if( data && data.param1 )
131 data.param1.SetCargoPos( i );
132 data.param1.SetPos();
136 m_FocusedItemPosition =
Math.
Min( m_ShowedItemPositions.Count() - 1, m_FocusedItemPosition );
145 item.GetInventory().GetCurrentInventoryLocation( il );
148 #ifdef PLATFORM_CONSOLE
153 if( m_ShowedItemPositions.Contains( item ) )
155 ref Param3<ref Icon, int, int> data = m_ShowedItemPositions.Get( item );
158 if( data.param2 !=
x || data.param3 !=
y )
162 #ifdef PLATFORM_CONSOLE
165 #ifdef PLATFORM_WINDOWS
166 data.param1.SetPosX( data.param2 );
167 data.param1.SetPosY( data.param3 );
170 data.param1.UpdateInterval();
178 #ifndef PLATFORM_CONSOLE
182 int index =
GetGame().
GetPlayer().GetHumanInventory().FindUserReservedLocationIndex( item );
185 GetGame().
GetPlayer().GetHumanInventory().GetUserReservedLocation( index, il );
187 ref
Icon icon =
new Icon(
this,
false );
188 m_Icons.Insert( icon );
190 m_ShowedLockPositions.Insert( item,
new Param3<ref Icon, int, int>( icon, 1, 1 ) );
191 item.GetOnReleaseLock().Insert( ReleaseLock );
199 #ifndef PLATFORM_CONSOLE
200 if( m_ShowedLockPositions.Contains( item ) )
202 Icon ic = m_ShowedLockPositions.
Get( item ).param1;
203 m_Icons.RemoveItem( ic );
204 m_ShowedLockPositions.
Remove( item );
205 item.GetOnReleaseLock().Remove( ReleaseLock );
212 #ifdef PLATFORM_CONSOLE
242 m_Cargo = item.GetInventory().GetCargoFromIndex(cargo_index);
243 m_CargoIndex = cargo_index;
245 m_Entity.GetOnItemAddedIntoCargo().Insert( AddedToCargo );
246 m_Entity.GetOnItemRemovedFromCargo().Insert( RemovedFromCargo );
247 m_Entity.GetOnItemMovedInCargo().Insert( MovedInCargo );
249 m_Entity.GetOnReleaseLock().Insert( ReleaseLock );
260 int prev_count = m_ShowedItemPositions.Count();
272 #ifdef PLATFORM_CONSOLE
291 if (
m_Entity.CanDisplayCargo() &&
m_Entity.GetInventory().GetCargoFromIndex(m_CargoIndex) )
294 if ( m_IsAttachment && m_CargoHeader )
296 m_FalseHeaderTextWidget.SetText(
name);
298 m_FalseHeaderTextWidget.Update();
299 m_FalseHeaderTextWidget.GetScreenSize(
x,
y );
300 m_CargoHeader.FindAnyWidget(
"grid_container_header" ).SetSize( 1,
y +
InventoryMenu.GetHeightMultiplied( 10 ) );
301 m_CargoHeader.Update();
303 if (m_AlternateFalseHeaderTextWidget)
305 m_AlternateFalseHeaderTextWidget.SetText(
name);
318 m_ShowedItemPositions.Clear();
322 #ifdef PLATFORM_CONSOLE
323 int cargo_height = 1;
325 int cargo_height =
m_Entity.GetInventory().GetCargoFromIndex(m_CargoIndex).GetHeight();
328 for (
int j = 0; j < cargo_height; j++ )
335 #ifdef PLATFORM_WINDOWS
336 #ifndef PLATFORM_CONSOLE
337 row.SetWidth(
m_Entity.GetInventory().GetCargoFromIndex(m_CargoIndex).GetWidth(),
false );
341 row.GetRootWidget().SetSort( j,
false );
342 m_Rows.Insert( row );
346 row.GetRootWidget().FindAnyWidget(
"Icon0" ).GetScreenSize(
y, m_IconSize );
347 #ifdef PLATFORM_WINDOWS
348 #ifndef PLATFORM_CONSOLE
349 row.GetRootWidget().FindAnyWidget(
"Spacer0" ).GetScreenSize( m_SpaceSize,
y );
353 m_Resizer2.ResizeParentToChild();
354 m_Resizer1.ResizeParentToChild();
359 m_Resizer1.ResizeParentToChild();
374 #ifdef PLATFORM_CONSOLE
375 #ifndef PLATFORM_WINDOWS
376 return CargoList.Cast( m_Cargo ).GetTotalWeight( null );
391 #ifdef PLATFORM_CONSOLE
392 #ifndef PLATFORM_WINDOWS
393 return CargoList.Cast( m_Cargo ).GetMaxWeight();
401 if ( item && m_ShowedItemPositions.Contains( item ) )
403 Param3<ref Icon, int, int> data = m_ShowedItemPositions.
Get( item );
411 if ( m_Cargo == null )
413 Print(
"Attempted to get icon on cargo container, but cargo was null!");
424 return GetIcon( m_FocusedItemPosition );
433 GetRootWidget().GetScreenSize(
x,
y );
443 GetRootWidget().GetPos(
x,
y );
453 GetRootWidget().GetScreenPos(
x,
y );
461 if( m_FocusedItemPosition >= m_Icons.Count() )
462 m_FocusedItemPosition = m_Icons.Count() - 1;
464 if( icon && !icon.IsActive() )
467 Inventory.GetInstance().UpdateConsoleToolbar();
476 int diff = rows - m_Rows.Count();
480 for( i = m_Rows.Count() - 1; i >= rows; i-- )
488 for( i = m_Rows.Count(); i < rows; i++ )
494 row.GetRootWidget().SetSort( i );
495 m_Rows.Insert( row );
500 m_Resizer2.ResizeParentToChild();
501 m_Resizer1.ResizeParentToChild();
506 #ifdef PLATFORM_CONSOLE
507 if ( !m_ResizeTimer )
508 m_ResizeTimer =
new Timer();
509 if ( m_ResizeTimer.IsRunning() )
510 m_ResizeTimer.Stop();
511 m_ResizeTimer.Run( 0.05,
this,
"RefreshImpl" );
527 data.param1.UpdateInterval();
534 #ifdef PLATFORM_CONSOLE
536 #ifdef PLATFORM_WINDOWS
537 pos_y = pos_y * 5 + pos_x;
546 if ( item.GetInventory().GetFlipCargo() )
547 icon.
SetSize( size_y, size_x );
549 icon.
SetSize( size_x, size_y );
555 icon.
InitEx( item, refresh );
561 return InitIconEx( icon, item, pos_x, pos_y );
566 return m_ShowedItemPositions.Contains( item );
575 if( item && player.CanDropEntity( item ) )
577 if( item.GetTargetQuantityMax() < item.GetQuantity() )
578 item.SplitIntoStackMaxClient( null, -1 );
580 player.PhysicalPredictiveDropItem( item );
589 super.SetDefaultFocus(while_micromanagment_mode);
592 m_FocusedItemPosition = 0;
616 icon.SetActive(
false );
619 m_FocusedItemPosition = 0;
626 int max_row = ( m_Icons.Count() - 1) / ROWS_NUMBER_XBOX;
628 if ( max_row > focused_row )
631 if ( m_FocusedItemPosition >= m_Icons.Count() )
633 m_FocusedItemPosition = m_Icons.Count() - 1;
648 if ( focused_row > 0 )
662 if ( m_Icons.Count() > 0)
667 int row_max = row_min + ROWS_NUMBER_XBOX - 1;
669 if ( row_max >= m_Icons.Count() )
671 row_max = m_Icons.Count() - 1;
674 m_FocusedItemPosition++;
675 if( m_FocusedItemPosition > row_max )
677 m_FocusedItemPosition = row_min;
686 if ( m_Icons.Count() > 0)
691 int row_max = row_min + ROWS_NUMBER_XBOX - 1;
693 if ( row_max >= m_Icons.Count() )
695 row_max = m_Icons.Count() - 1;
698 m_FocusedItemPosition--;
699 if( m_FocusedItemPosition < row_min )
701 m_FocusedItemPosition = row_max;
721 super.SetLastActive();
726 m_FocusedItemPosition = ( ( m_Rows.Count() - 1 ) * ROWS_NUMBER_XBOX );
732 super.SetActive( active );
741 return ( item != null );
758 return m_Icons.Count() == 0;
763 PluginRecipesManager recipes_manager = PluginRecipesManager.Cast(
GetPlugin( PluginRecipesManager ) );
764 return recipes_manager.GetValidRecipes( entity1, entity2, null, player );
802 if( entity.HasQuantity() && entity.CanBeSplit() )
804 entity.OnRightClick();
805 Icon icon = m_ShowedItemPositions.
Get( entity ).param1;
853 if( focused_item != selected_item )
857 if( selected_item.GetInventory().CanRemoveEntity() &&
m_Entity )
859 bool can_add =
m_Entity.GetInventory().CanAddEntityInCargo( selected_item, selected_item.GetInventory().GetFlipCargo());
860 bool in_cargo = !player.GetInventory().HasEntityInInventory( selected_item ) || !
m_Entity.GetInventory().HasEntityInCargo( selected_item );
861 if( can_add && in_cargo )
863 player.PredictiveTakeEntityToTargetCargo(
m_Entity, selected_item );
871 m_FocusedItemPosition = 0;
887 else if ( focused_item && focused_item.GetInventory().CanRemoveEntity() )
894 player.PredictiveSwapEntities( item_in_hands, focused_item );
900 if( player.GetHumanInventory().CanAddEntityInHands( focused_item ) )
902 player.PredictiveTakeEntityToHands( focused_item );
920 if( item_in_hands && prev_item )
931 m_CargoHeader.Show(show);
937 m_AlternateFalseHeaderTextWidget = w;
void Inventory(LayoutHolder parent)
protected void GetActionManager()
FindInventoryLocationType
flags for searching locations in inventory
class PluginItemDiagnosticEventHandler extends ScriptedWidgetEventHandler m_Entity
PluginBase GetPlugin(typename plugin_type)
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
bool CanSetActionFromInventory(ItemBase mainItem, ItemBase targetItem)
bool CanPerformActionFromInventory(ItemBase mainItem, ItemBase targetItem)
proto void GetInventoryItemSize(InventoryItem item, out int width, out int height)
proto native DayZPlayer GetPlayer()
represents base for cargo storage for entities
proto native int GetHeight()
proto bool GetItemSize(int index, out int w, out int h)
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
proto native int GetWidth()
override void SetPreviousActive(bool force=false)
int GetRecipeCount(bool recipe_anywhere, ItemBase entity1, ItemBase entity2, PlayerBase player)
override void UnfocusAll()
void MovedInCargo(EntityAI item)
void UpdateRowVisibility(int count)
Icon InitIcon(Icon icon, EntityAI item, int pos_x, int pos_y)
override float GetFocusedContainerYPos(bool contents=false)
void ShowFalseCargoHeader(bool show)
protected ref SizeToChild m_Resizer1
void SetLock(EntityAI item)
protected int m_CargoIndex
override bool IsItemActive()
override void SetNextActive()
protected Widget m_CargoContainer
int GetMaxCargoCapacity()
void AddedToCargoEx(EntityAI item, bool refresh=true)
override bool SelectItem()
protected CargoBase m_Cargo
override void UpdateInterval()
Icon InitIconEx(Icon icon, EntityAI item, int pos_x, int pos_y, bool refresh=true)
override bool TransferItem()
void SetAlternateFalseTextHeaderWidget(TextWidget w)
override bool TransferItemToVicinity()
void AddedToCargo(EntityAI item)
Icon GetIcon(EntityAI item)
bool HasItem(EntityAI item)
void CargoContainer(LayoutHolder parent, bool is_attachment=false)
protected ref array< ref CargoContainerRow > m_Rows
protected float m_SpaceSize
override float GetFocusedContainerYScreenPos(bool contents=false)
void SetEntity(EntityAI item, int cargo_index=0, bool immedUpdate=true)
override void SetLastFocus()
protected ref Timer m_ResizeTimer
override void SetActive(bool active)
protected ref map< EntityAI, ref Param3< ref Icon, int, int > > m_ShowedLockPositions
protected ref SizeToChild m_Resizer2
protected Widget m_ItemsContainer
protected ref array< ref Icon > m_Icons
protected bool m_IsAttachment
override void SetNextRightActive()
override Header GetHeader()
override bool CanCombineAmmo()
override bool EquipItem()
void RemovedFromCargo(EntityAI item)
override float GetFocusedContainerHeight(bool contents=false)
override bool IsItemWithQuantityActive()
protected TextWidget m_AlternateFalseHeaderTextWidget
protected TextWidget m_FalseHeaderTextWidget
override void SetDefaultFocus(bool while_micromanagment_mode=false)
protected ref map< EntityAI, ref Param3< ref Icon, int, int > > m_ShowedItemPositions
protected const int ROWS_NUMBER_XBOX
override void SetLastActive()
override void SetNextLeftActive()
override void SetLayoutName()
override EntityAI GetFocusedItem()
void ReleaseLock(EntityAI item)
override bool SplitItem()
protected float m_IconSize
protected Widget m_CargoHeader
script counterpart to engine's class Inventory
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
void SetSize(int x, int y)
override void SetActive(bool active)
void InitEx(EntityAI obj, bool refresh=true)
void SetPosEx(bool refresh=true)
bool CombineItems(EntityAI entity1, EntityAI entity2)
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
proto native bool GetFlip()
returns flip status of cargo
override bool IsTakeable()
EntityAI GetSelectedItem()
Container GetSelectedContainer()
void SetSelectedItem(EntityAI selected_item, Container selected_container, Widget selected_widget, SlotsIcon selected_icon)
static ItemManager GetInstance()
void Remove(LayoutHolder container)
static int HasItemQuantity(notnull EntityAI item)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float Min(float x, float y)
Returns smaller of two given values.
static proto float Ceil(float f)
Returns ceil of value.
proto int ToUpper()
Changes string to uppercase. Returns length.