24#ifndef PLATFORM_CONSOLE
43#ifndef PLATFORM_CONSOLE
71 item.GetInventory().GetCurrentInventoryLocation( il );
84 ref
Icon icon =
new Icon(
this,
false );
93 #ifdef PLATFORM_CONSOLE
94 for (
int i = 0; i <
m_Cargo.GetItemCount(); i++ )
100 data.param1.SetCargoPos( i );
101 data.param1.SetPos();
122 m_Icons.RemoveItem( data.param1 );
128 #ifdef PLATFORM_CONSOLE
129 for(
int i = 0; i <
m_Cargo.GetItemCount(); i++ )
133 if( data && data.param1 )
135 data.param1.SetCargoPos( i );
136 data.param1.SetPos();
149 item.GetInventory().GetCurrentInventoryLocation( il );
152 #ifdef PLATFORM_CONSOLE
162 if( data.param2 !=
x || data.param3 !=
y )
166 #ifdef PLATFORM_CONSOLE
167 data.param1.SetCargoPos( data.param3 );
169 #ifdef PLATFORM_WINDOWS
170 data.param1.SetPosX( data.param2 );
171 data.param1.SetPosY( data.param3 );
174 data.param1.UpdateInterval();
182 #ifndef PLATFORM_CONSOLE
186 int index =
g_Game.GetPlayer().GetHumanInventory().FindUserReservedLocationIndex( item );
189 g_Game.GetPlayer().GetHumanInventory().GetUserReservedLocation( index, il );
191 ref
Icon icon =
new Icon(
this,
false );
203 #ifndef PLATFORM_CONSOLE
216 #ifdef PLATFORM_CONSOLE
246 m_Cargo = item.GetInventory().GetCargoFromIndex(cargo_index);
267 for ( i = 0; i <
m_Cargo.GetItemCount(); i++ )
276 #ifdef PLATFORM_CONSOLE
326 #ifdef PLATFORM_CONSOLE
327 int cargo_height = 1;
332 for (
int j = 0; j < cargo_height; j++ )
339 #ifdef PLATFORM_WINDOWS
340 #ifndef PLATFORM_CONSOLE
345 row.GetRootWidget().SetSort( j,
false );
350 row.GetRootWidget().FindAnyWidget(
"Icon0" ).GetScreenSize(
y,
m_IconSize );
351 #ifdef PLATFORM_WINDOWS
352 #ifndef PLATFORM_CONSOLE
353 row.GetRootWidget().FindAnyWidget(
"Spacer0" ).GetScreenSize(
m_SpaceSize,
y );
358#ifndef PLATFORM_CONSOLE
365#ifndef PLATFORM_CONSOLE
384 #ifdef PLATFORM_CONSOLE
385 #ifndef PLATFORM_WINDOWS
386 return CargoList.Cast(
m_Cargo ).GetTotalWeight( null );
390 for (
int i = 0; i <
m_Cargo.GetItemCount(); ++i )
401 #ifdef PLATFORM_CONSOLE
402 #ifndef PLATFORM_WINDOWS
403 return CargoList.Cast(
m_Cargo ).GetMaxWeight();
426 if ( index >= 0 &&
m_Cargo.GetItemCount() > index )
442 GetRootWidget().GetScreenSize(
x,
y );
452 GetRootWidget().GetPos(
x,
y );
462 GetRootWidget().GetScreenPos(
x,
y );
473 if( icon && !icon.IsActive() )
476 Inventory.GetInstance().UpdateConsoleToolbar();
494 Error(
string.Format(
"%1::UpdateRowVisibility - CargoBase is NULL for entity %2 at position %3",
ToString(),
m_Entity.GetType(),
m_Entity.GetPosition()));
497 int diff = rows -
m_Rows.Count();
500 for(i =
m_Rows.Count() - 1; i >= rows; i--)
508 for(i =
m_Rows.Count(); i < rows; i++)
514 row.GetRootWidget().SetSort(i);
521 #ifndef PLATFORM_CONSOLE
528 #ifdef PLATFORM_CONSOLE
549 data.param1.UpdateInterval();
556 #ifdef PLATFORM_CONSOLE
558 #ifdef PLATFORM_WINDOWS
559 pos_y = pos_y * 5 + pos_x;
568 if ( item.GetInventory().GetFlipCargo() )
569 icon.
SetSize( size_y, size_x );
571 icon.
SetSize( size_x, size_y );
577 icon.
InitEx( item, refresh );
583 return InitIconEx( icon, item, pos_x, pos_y );
595 Man player =
g_Game.GetPlayer();
599 if( item && player.CanDropEntity( item ) )
601 if( item.GetTargetQuantityMax() < item.GetQuantity() )
602 item.SplitIntoStackMaxClient( null, -1 );
604 player.PhysicalPredictiveDropItem( item );
614 super.SetDefaultFocus(while_micromanagment_mode);
641 icon.SetActive(
false );
653 if ( max_row > focused_row )
673 if ( focused_row > 0 )
694 if ( row_max >=
m_Icons.Count() )
718 if ( row_max >=
m_Icons.Count() )
746 super.SetLastActive();
752 int focusedIconCount =
m_Icons.Count();
757 int diff = focusedIconCount - iconMax;
771 super.SetActive( active );
780 return ( item != null );
802 PluginRecipesManager recipes_manager = PluginRecipesManager.Cast(
GetPlugin( PluginRecipesManager ) );
803 return recipes_manager.GetValidRecipes( entity1, entity2, null, player );
822 if (CanTakeToInventory())
859 if( focused_item != selected_item )
863 if( selected_item.GetInventory().CanRemoveEntity() &&
m_Entity )
865 bool can_add =
m_Entity.GetInventory().CanAddEntityInCargo( selected_item, selected_item.GetInventory().GetFlipCargo());
866 bool in_cargo = !player.GetInventory().HasEntityInInventory( selected_item ) || !
m_Entity.GetInventory().HasEntityInCargo( selected_item );
867 if( can_add && in_cargo )
869 player.PredictiveTakeEntityToTargetCargo(
m_Entity, selected_item );
893 else if ( focused_item && focused_item.GetInventory().CanRemoveEntity() )
900 player.PredictiveSwapEntities( item_in_hands, focused_item );
906 if( player.GetHumanInventory().CanAddEntityInHands( focused_item ) )
908 player.PredictiveTakeEntityToHands( focused_item );
928 if( item_in_hands && prev_item )
void Inventory(LayoutHolder parent)
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
bool CanSetActionFromInventory(ItemBase mainItem, ItemBase targetItem)
bool CanPerformActionFromInventory(ItemBase mainItem, ItemBase targetItem)
represents base for cargo storage for entities
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)
TextWidget m_AlternateFalseHeaderTextWidget
override float GetFocusedContainerYPos(bool contents=false)
void ShowFalseCargoHeader(bool show)
void SetLock(EntityAI item)
override bool IsItemActive()
override void SetNextActive()
int GetMaxCargoCapacity()
void AddedToCargoEx(EntityAI item, bool refresh=true)
override bool SelectItem()
const int ROWS_NUMBER_XBOX
int GetAttachmentSlotID()
ref array< ref Icon > m_Icons
override void UpdateInterval()
Icon InitIconEx(Icon icon, EntityAI item, int pos_x, int pos_y, bool refresh=true)
override bool TransferItem()
ref SizeToChild m_Resizer2
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)
override float GetFocusedContainerYScreenPos(bool contents=false)
void SetEntity(EntityAI item, int cargo_index=0, bool immedUpdate=true)
override void SetLastFocus()
override void SetActive(bool active)
int m_FocusedItemPosition
void SetAttachmentSlotID(int slotID)
ref map< EntityAI, ref Param3< ref Icon, int, int > > m_ShowedItemPositions
override void SetNextRightActive()
override Header GetHeader()
override bool CanCombineAmmo()
void RemovedFromCargo(EntityAI item)
override float GetFocusedContainerHeight(bool contents=false)
override bool IsItemWithQuantityActive()
ref SizeToChild m_Resizer1
ref array< ref CargoContainerRow > m_Rows
TextWidget m_FalseHeaderTextWidget
override void SetDefaultFocus(bool while_micromanagment_mode=false)
ref map< EntityAI, ref Param3< ref Icon, int, int > > m_ShowedLockPositions
override void SetLastActive()
override void SetNextLeftActive()
override void SetLayoutName()
override EntityAI GetFocusedItem()
void ReleaseLock(EntityAI item)
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 bool GetFlip()
returns flip status of cargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
override bool CanBeSplit()
override bool CanPutIntoHands(EntityAI parent)
override bool IsTakeable()
EntityAI GetSelectedItem()
Container GetSelectedContainer()
void SetSelectedItemEx(EntityAI selected_item, Container selected_container, LayoutHolder selected_icon)
static ItemManager GetInstance()
static int HasItemQuantity(notnull EntityAI item)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
void Error(string err)
Messagebox with error message.
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.
FindInventoryLocationType
flags for searching locations in inventory
PluginBase GetPlugin(typename plugin_type)
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]