3 protected ref CargoContainer m_CargoGrid;
4 protected int m_CargoIndex = -1;
6 void ContainerWithCargo(
Container parent,
int sort = -1 )
11 m_CargoGrid =
new CargoContainer(
this );
12 Insert( m_CargoGrid );
14 m_CargoGrid.GetRootWidget().SetSort( 1 );
16 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( m_MainWidget,
this,
"DraggingOverGrid" );
17 RecomputeOpenedContainers();
20 override bool IsDisplayable()
29 return m_CargoGrid.IsEmpty();
32 override bool IsItemActive()
34 return m_CargoGrid.IsItemActive();
37 override bool CanCombine()
39 return m_CargoGrid.CanCombine();
42 override bool CanCombineAmmo()
44 return m_CargoGrid.CanCombineAmmo();
47 override bool IsItemWithQuantityActive()
49 return m_CargoGrid.IsItemWithQuantityActive();
52 void LockCargo(
bool value)
54 if( value != m_LockCargo )
64 SetOpenState(!m_Closed);
75 SetOpenForSlotIcon(
true);
82 m_SlotIcon.GetRadialIconPanel().Show( !m_LockCargo );
92 SetOpenForSlotIcon(
false);
99 m_SlotIcon.GetRadialIconPanel().Show( !m_LockCargo );
105 return !m_Closed && !m_LockCargo;
112 if (
m_Entity.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) || !
m_Entity.CanDisplayCargo() )
115 if ( m_CargoGrid.IsVisible() )
117 RecomputeOpenedContainers();
123 if ( !m_CargoGrid.IsVisible() )
125 RecomputeOpenedContainers();
129 super.UpdateInterval();
130 m_CargoGrid.UpdateInterval();
140 m_SlotIcon.GetRadialIconPanel().Show( !hide );
145 override bool IsFirstContainerFocused()
147 return m_CargoGrid.IsFirstContainerFocused();
150 override bool IsLastContainerFocused()
152 return m_CargoGrid.IsLastContainerFocused();
155 override void SetDefaultFocus(
bool while_micromanagment_mode =
false )
157 m_CargoGrid.SetDefaultFocus( while_micromanagment_mode );
160 override void UnfocusAll()
162 m_CargoGrid.Unfocus();
167 return m_CargoGrid.SplitItem();
170 override bool EquipItem()
172 return m_CargoGrid.EquipItem();
175 override bool TransferItem()
177 return m_CargoGrid.TransferItem();
180 override bool TransferItemToVicinity()
182 return m_CargoGrid.TransferItemToVicinity();
185 override bool InspectItem()
187 return m_CargoGrid.InspectItem();
190 void SetEntity(
EntityAI entity,
int cargo_index = 0,
bool immedUpdate =
true )
193 m_CargoIndex = cargo_index;
195 SetOpenState(
true );
197 m_CargoGrid.SetEntity( entity, immedUpdate );
198 m_CargoGrid.UpdateHeaderText();
199 m_ClosableHeader.SetItemPreview( entity );
200 CheckHeaderDragability();
203 if (
m_Entity.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) || !
m_Entity.CanDisplayCargo() )
211 GetMainWidget().Update();
220 override EntityAI GetFocusedContainerEntity()
230 string name = w.GetName();
231 name.Replace(
"PanelWidget",
"Render" );
242 return ipw.GetItem();
253 if( !player.CanManipulateInventory() )
258 EntityAI item = GetItemPreviewItem( w );
265 if( !item.GetInventory().CanRemoveEntity() )
272 #ifdef PLATFORM_CONSOLE
281 c_x = cargo.GetHeight();
282 c_y = cargo.GetWidth();
286 #ifdef PLATFORM_CONSOLE
288 y = cargo.GetItemCount();
291 dst.SetCargoAuto(cargo, item,
x,
y, item.GetInventory().GetFlipCargo());
294 #ifdef PLATFORM_CONSOLE
295 if( dst.IsValid() &&
m_Entity.GetInventory().LocationCanAddEntityEx(dst))
297 if(
m_Entity && c_x >
x && c_y >
y &&
m_Entity.GetInventory().LocationCanAddEntityEx(dst))
303 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
307 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
314 ItemManager.GetInstance().ShowSourceDropzone( item );
317 if( w.FindAnyWidget(
"Cursor") )
319 w.FindAnyWidget(
"Cursor").SetColor( color );
323 string name = w.GetName();
324 name.Replace(
"PanelWidget",
"Cursor" );
325 if( w.FindAnyWidget(
name ) )
327 w.FindAnyWidget(
name ).SetColor( color );
334 void DropReceived(
Widget w,
int x,
int y )
337 GetMainWidget().Update();
338 GetMainWidget().GetScreenSize( xx, yy );
341 GetMainWidget().FindAnyWidget(
"Background").Show(
true );
342 GetMainWidget().FindAnyWidget(
"Background").SetSize( xx, yy );
344 EntityAI item = GetItemPreviewItem( w );
350 #ifdef PLATFORM_CONSOLE
351 if( m_CargoGrid.HasItem( item ) )
357 #ifdef PLATFORM_CONSOLE
368 c_x = cargo.GetHeight();
369 c_y = cargo.GetWidth();
373 #ifdef PLATFORM_CONSOLE
375 y = cargo.GetItemCount();
378 dst.SetCargoAuto(cargo, item,
x,
y, item.GetInventory().GetFlipCargo());
382 item.GetInventory().GetCurrentInventoryLocation(src);
384 if(src.CompareLocationOnly(dst) && src.GetFlip() == dst.GetFlip())
387 #ifdef PLATFORM_CONSOLE
388 if(dst.IsValid() &&
m_Entity.GetInventory().LocationCanAddEntityEx(dst))
390 if( c_x >
x && c_y >
y &&
m_Entity.GetInventory().LocationCanAddEntityEx(dst))
397 Icon icon = m_CargoGrid.GetIcon( item );
399 if( icon && w && w.FindAnyWidget(
"Cursor") )
401 w.FindAnyWidget(
"Cursor").SetColor(
ColorManager.BASE_COLOR );
415 if( !item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory() )
418 float stackable = item_base.GetTargetQuantityMax();
420 if( stackable == 0 || stackable >= item_base.GetQuantity() )
422 player.PredictiveTakeEntityToHands( item );
424 else if( stackable != 0 && stackable < item_base.GetQuantity() )
426 item_base.SplitIntoStackMaxHandsClient( player );
430 override void DraggingOverHeader(
Widget w,
int x,
int y,
Widget receiver )
432 DraggingOver( w,
x,
y, receiver );
435 override void DraggingOver(
Widget w,
int x,
int y,
Widget receiver )
439 EntityAI item = GetItemPreviewItem( w );
444 if( item.GetInventory().CanRemoveEntity() && player.CanManipulateInventory() &&
m_Entity.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && !
m_Entity.GetInventory().HasEntityInCargo( item ) )
450 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
454 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
460 ItemManager.GetInstance().ShowSourceDropzone( item );
464 override void OnDropReceivedFromHeader(
Widget w,
int x,
int y,
Widget receiver )
466 EntityAI item = GetItemPreviewItem( w );
474 if(
GetEntity() && item.GetInventory().GetCurrentInventoryLocation(src))
479 player.PredictiveTakeToDst(src, dst);
482 bool can_add =
m_Entity.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() );
483 bool in_cargo = !player.GetInventory().HasEntityInInventory( item ) || !
m_Entity.GetInventory().HasEntityInCargo( item );
484 if( can_add && in_cargo )