4 protected int m_SlotsCount;
15 InitIconsContainers();
18 WidgetEventHandler.GetInstance().RegisterOnChildAdd( m_MainWidget,
this,
"OnChildAdd" );
19 WidgetEventHandler.GetInstance().RegisterOnChildRemove( m_MainWidget,
this,
"OnChildRemove" );
26 RecomputeOpenedContainers();
31 m_CollapsibleHeader.SetName(
m_Entity.GetDisplayName() );
34 override bool IsDisplayable()
36 return !
IsEmpty() || CanDisplayAnyCategory();
39 override void UpdateInterval()
43 if(
m_Entity.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) || m_Hidden )
45 if( m_Body.Count() > 0 && !m_Hidden )
46 m_CollapsibleHeader.OnHide();
48 GetMainWidget().Show(
false );
52 if( m_Body.Count() > 0 && !m_Hidden )
54 if( m_Body.Count() > 0 && !m_Hidden )
55 m_CollapsibleHeader.OnShow();
57 for (i = m_SlotsCount; i < m_Body.Count(); i++)
62 if (
m_Entity.CanDisplayAttachmentCategory( row.GetCategoryIdentifier() ))
64 if ( row.IsDisplayable() )
66 ShowInSlots( row.GetCategoryIdentifier(),
true );
74 ShowInSlots( row.GetCategoryIdentifier(),
false );
83 ShowInSlots( row.GetCategoryIdentifier(),
false );
93 ContainerWithCargo cargo = ContainerWithCargo.Cast(m_Body[i]);
98 m_CargoSlotsIcon.m_MainWidget.Show(
true);
99 if (!cargo.IsVisible())
106 m_CargoSlotsIcon.m_MainWidget.Show(
false);
107 if (cargo.IsVisible())
112 cargo.UpdateInterval();
114 RecomputeOpenedContainers();
119 for ( i = 0; i < m_SlotsCount; i++)
123 if (slots.IsDisplayable())
134 GetMainWidget().Show(
true );
139 void LoadAttachmentCategoriesIcon(
SlotsContainer items_cont,
string icon_name,
int slot_number )
141 SlotsIcon icon = items_cont.GetSlotIcon( slot_number );
142 ImageWidget image_widget = icon.GetGhostSlot();
143 image_widget.Show(
true );
147 int GetAttachmentCategoriesCount(
string config_path )
149 return GetGame().ConfigGetChildrenCount( config_path );
155 return items_cont.GetSlotsContainer();
160 return m_CargoSlotsIcon;
163 void ShowInSlots(
string category,
bool show )
165 int index = m_CategorySlotIndex.Get( category );
171 Widget icon_widget = items_cont.GetSlotIcon( slot_number ).GetMainWidget();
173 icon_widget.Show( show );
174 icon_widget.GetParent().Update();
175 icon_widget.GetParent().GetParent().Update();
176 icon_widget.GetParent().GetParent().GetParent().Update();
181 override bool CanDisplayAnyCategory()
183 int count = m_Body.Count();
185 for (
int i = m_SlotsCount; i < count; i++)
187 if (
Class.CastTo(row,m_Body[i]) &&
m_Entity.CanDisplayAttachmentCategory( row.GetCategoryIdentifier() ))
192 return super.CanDisplayAnyCategory();
195 override void UpdateRadialIcon()
199 if (
m_Entity.CanDisplayCargo() || CanDisplayAnyCategory())
201 m_SlotIcon.GetRadialIconPanel().Show(
true );
202 SetOpenForSlotIcon(!m_Hidden);
206 m_SlotIcon.GetRadialIconPanel().Show(
false );
211 string GetAttachmentCategory(
string config_path_attachment_categories,
int i )
213 string attachment_category;
214 GetGame().ConfigGetChildName(config_path_attachment_categories, i, attachment_category);
215 return attachment_category;
218 string GetIconName(
string config_path_attachment_categories,
string attachment_category )
220 string icon_path = config_path_attachment_categories+
" " + attachment_category +
" icon";
222 GetGame().ConfigGetText(icon_path, icon_name);
226 int GetViewIndex(
string config_path_attachment_categories,
string attachment_category )
228 string preview_path = config_path_attachment_categories+
" " + attachment_category +
" view_index";
229 return GetGame().ConfigGetInt( preview_path );;
242 override void ExpandCollapseContainer()
244 if (m_OpenedContainers.Count() > m_ActiveIndex)
251 SlotsIcon icon = c.GetFocusedSlotsIcon();
262 RecomputeOpenedContainers();
267 bool IsHeaderActive()
269 return m_CollapsibleHeader.IsActive();
272 void InitIconsContainers()
277 string config_path_attachment_categories =
"CfgVehicles " + type +
" GUIInventoryAttachmentsProps";
278 int attachments_categories_count = GetAttachmentCategoriesCount( config_path_attachment_categories );
279 int categories_count = attachments_categories_count;
280 if (
m_Entity.GetInventory().GetCargo())
289 for (
int i = 0; i < row_count; i++ )
292 m_Body.Insert( items_cont );
293 m_OpenedContainers.Insert( items_cont );
296 if (i == ( row_count - 1 ) && categories_count %
ITEMS_IN_ROW != 0)
297 items_cont.GetSlotsContainer().SetColumnCount( categories_count %
ITEMS_IN_ROW );
299 items_cont.GetSlotsContainer().SetColumnCount(
ITEMS_IN_ROW );
301 m_SlotsCount = row_count;
304 void InitGhostSlots()
307 string config_path_attachment_categories =
"CfgVehicles " + type +
" GUIInventoryAttachmentsProps";
309 int attachments_categories_count = GetAttachmentCategoriesCount( config_path_attachment_categories );
313 string attachment_category;
316 for (
int i = 0; i < attachments_categories_count; i++)
319 attachment_category = GetAttachmentCategory( config_path_attachment_categories, i );
320 icon_name = GetIconName( config_path_attachment_categories, attachment_category );
325 m_CategorySlotIndex.Insert( attachment_category, i );
326 icon = items_cont.GetSlotIcon( slot_number );
327 icon.GetGhostSlot().SetFlags(
WidgetFlags.IGNOREPOINTER );
329 LoadAttachmentCategoriesIcon( items_cont, icon_name, slot_number );
331 string config = config_path_attachment_categories +
" " + attachment_category +
" name";
335 icon.SetSlotDisplayName(
name);
340 ar.Init(attachments_categories_count, i, attachment_category, config_path_attachment_categories,
m_Entity, m_Body.Count() );
343 ar.SetSlotIcon(icon);
346 icon.GetRadialIconPanel().Show(
true );
348 icon.SetContainer(ar);
353 if (
m_Entity.GetInventory().GetCargo() )
355 items_cont = GetSlotsContainer( m_SlotsCount - 1 );
358 icon = items_cont.GetSlotIcon( attachments_categories_count );
359 icon.GetGhostSlot().Show(
true );
361 icon.SetSlotDisplayName(
m_Entity.ConfigGetString(
"GUIInventoryCargoName"));
362 icon.GetGhostSlot().SetFlags(
WidgetFlags.IGNOREPOINTER );
364 icon.GetRadialIconPanel().Show(
true );
365 icon.GetMainWidget().Show(
true );
367 ContainerWithCargo iwc =
new ContainerWithCargo(
this, -1 );
368 iwc.Get( 0 ).GetRootWidget().ClearFlags(
WidgetFlags.DRAGGABLE );
369 iwc.SetEntity(
m_Entity, 0,
false );
370 iwc.SetSlotIcon( icon );
373 icon.SetContainer(iwc);
374 m_CargoSlotsIcon = icon;
378 RecomputeOpenedContainers();
382 override void OnDropReceivedFromHeader(
Widget w,
int x,
int y,
Widget receiver )
387 string name = w.GetName();
388 name.Replace(
"PanelWidget",
"Render");
397 if(
m_Entity.GetInventory().CanAddAttachment( iw.GetItem() ) && iw.GetItem().GetInventory().CanRemoveEntity() )
399 GetGame().GetPlayer().PredictiveTakeEntityToTargetAttachment(
m_Entity, iw.GetItem() );
401 else if(
m_Entity.GetInventory().CanAddEntityToInventory( iw.GetItem() ) && iw.GetItem().GetInventory().CanRemoveEntity() )
407 override void DraggingOverHeader(
Widget w,
int x,
int y,
Widget receiver )
416 string name = w.GetName();
417 name.Replace(
"PanelWidget",
"Render");
424 if( !iw || !iw.GetItem() )
429 ItemManager.GetInstance().ShowSourceDropzone( iw.GetItem() );
438 override void CollapseButtonOnMouseButtonDown(
Widget w )
442 for (
int i = 1; i < m_Body.Count(); i++)
444 m_Body.Get( i ).OnHide();
462 SetCollapsibleHeaderArrowState(m_Hidden);
463 if (m_CollapsibleHeader)
465 m_CollapsibleHeader.SetHeaderVisible(
true);
468 UpdateCollapseButtons();
469 RecomputeOpenedContainers();
474 if( IsDisplayable() )
478 SetOpenForSlotIcon(
true);
484 override void Close()
490 if (m_CargoSlotsIcon && m_CargoSlotsIcon.GetObject())
492 icon = m_CargoSlotsIcon;
494 else if (m_SlotIcon && m_SlotIcon.GetObject())
504 SetOpenForSlotIcon(
false,icon);
508 override void OnHide()
510 if (m_CollapsibleHeader)
512 bool b1 = !m_SlotIcon && !m_CargoSlotsIcon;
513 bool b2 = (!m_SlotIcon || !m_SlotIcon.IsVisible()) && m_CargoSlotsIcon && m_CargoSlotsIcon.IsVisible();
514 m_CollapsibleHeader.SetHeaderVisible(b1 || b2);
519 override bool CanOpenCloseContainerEx(
EntityAI focusedEntity)
521 if (m_OpenedContainers.Count() > m_ActiveIndex)
531 if (c && c.IsDisplayable())
540 override bool CanSplitEx(
EntityAI focusedEntity)