DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ InitAttachmentGrid()

void Attachments::InitAttachmentGrid ( int att_row_index)
inlineprotected

См. определение в файле Attachments.c строка 458

459 {
460 SlotsIcon icon;
461 int i;
462 m_RowIndex = att_row_index;
463
464 int number_of_rows = Math.Ceil( m_AttachmentSlotNames.Count() / ITEMS_IN_ROW );
465 string name = m_Entity.GetDisplayName();
466 name.ToUpper();
467
468 m_AttachmentsContainer = new AttachmentsWrapper( m_Parent );
469 m_AttachmentsContainer.SetParent( this );
470 m_AttachmentsContainer.SetFalseAttachmentsHeaderText(name);
471 m_AttachmentsContainer.GetRootWidget().SetSort( att_row_index );
472 m_Parent.Insert( m_AttachmentsContainer, att_row_index );
473
474 for ( i = 0; i < number_of_rows; i++ )
475 {
476 SlotsContainer ic = new SlotsContainer( m_AttachmentsContainer, m_Entity );
477 m_AttachmentsContainer.Insert( ic );
478
479 if( i == ( number_of_rows - 1 ) && m_AttachmentSlotNames.Count() % ITEMS_IN_ROW != 0 )
480 {
481 ic.SetColumnCount( m_AttachmentSlotNames.Count() % ITEMS_IN_ROW );
482 }
483 else
484 {
485 ic.SetColumnCount( ITEMS_IN_ROW );
486 }
487
488 for( int j = 0; j < ITEMS_IN_ROW; j++ )
489 {
490 icon = ic.GetSlotIcon( j );
491 WidgetEventHandler.GetInstance().RegisterOnDropReceived( icon.GetMainWidget(), m_Parent, "OnDropReceivedFromHeader2" );
492 WidgetEventHandler.GetInstance().RegisterOnDropReceived( icon.GetGhostSlot(), m_Parent, "OnDropReceivedFromHeader2" );
493 WidgetEventHandler.GetInstance().RegisterOnDropReceived( icon.GetPanelWidget(), m_Parent, "OnDropReceivedFromHeader2" );
494
495 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( icon.GetMainWidget(), m_Parent, "DraggingOverHeader" );
496 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( icon.GetGhostSlot(), m_Parent, "DraggingOverHeader" );
497 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( icon.GetPanelWidget(), m_Parent, "DraggingOverHeader" );
498
499 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown( icon.GetMainWidget(), m_Parent, "MouseClick2" );
500 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown( icon.GetGhostSlot(), m_Parent, "MouseClick2" );
501 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown( icon.GetPanelWidget(), m_Parent, "MouseClick2" );
502 }
503 }
504
505 for ( i = 0; i < m_AttachmentSlotNames.Count(); i++ )
506 {
507 icon = SlotsContainer.Cast( m_AttachmentsContainer.Get( ( i / ITEMS_IN_ROW ) ) ).GetSlotIcon( i % ITEMS_IN_ROW );
508 WidgetEventHandler.GetInstance().RegisterOnDoubleClick( icon.GetPanelWidget(), m_Parent, "DoubleClick" );
509
510 string path = "CfgSlots" + " Slot_" + m_AttachmentSlotNames[i];
511
512 //Show different magazine icon for firearms and pistols
513 if ( m_AttachmentSlotNames[i] == "magazine" )
514 {
515 if ( !m_Entity.IsInherited( Pistol_Base ) )
516 path = "CfgSlots" + " Slot_" + "magazine2";
517 }
518
519 string icon_name = ""; //icon_name must be in format "set:<setname> image:<imagename>"
520 if( GetGame().ConfigGetText( path + " ghostIcon", icon_name ) && icon_name != "" )
521 icon.GetGhostSlot().LoadImageFile( 0, StaticGUIUtils.VerifyIconImageString(StaticGUIUtils.IMAGESETGROUP_INVENTORY,icon_name) );
522 int slot_id = InventorySlots.GetSlotIdFromString( m_AttachmentSlotNames[i] );
523 m_AttachmentSlots.Insert( slot_id, icon );
524 m_AttachmentIDOrdered.Insert(slot_id);
525
526 icon.SetSlotID(slot_id);
527 icon.SetSlotDisplayName(InventorySlots.GetSlotDisplayName(slot_id));
528
529 EntityAI item = m_Entity.GetInventory().FindAttachment( slot_id );
530 if( item )
532 else
533 icon.Clear();
534
535 if (m_Entity.CanDisplayAttachmentSlot(slot_id))
536 {
537 icon.GetMainWidget().Show( true );
538 }
539 else
540 {
541 icon.GetMainWidget().Show( false );
542 }
543 }
544
545 if( m_AttachmentSlotNames.Count() > 0 )
546 {
547 int row_index = number_of_rows - 1;
548 SlotsContainer row_last = SlotsContainer.Cast( m_AttachmentsContainer.Get( row_index ) );
549 if( row_last )
550 {
551 for( int k = ((m_AttachmentSlotNames.Count() - 1) % ITEMS_IN_ROW) + 1; k < ITEMS_IN_ROW; k++ )
552 {
553 row_last.GetSlotIcon( k ).GetMainWidget().Show( false );
554 }
555 row_last.GetRootWidget().Update();
556 row_last.GetRootWidget().GetParent().Update();
557 }
558 }
559
560 m_AttachmentsContainer.RecomputeOpenedContainers();
561 }
class LogManager EntityAI
const int ITEMS_IN_ROW
Определения Attachments.c:1
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
string path
Определения OptionSelectorMultistate.c:142
Container m_Parent
Определения Attachments.c:5
ref array< string > m_AttachmentSlotNames
Определения Attachments.c:8
ref AttachmentsWrapper m_AttachmentsContainer
Определения Attachments.c:7
void AttachmentAdded(EntityAI item, string slot, EntityAI parent)
Определения Attachments.c:416
int m_RowIndex
Определения Attachments.c:13
EntityAI m_Entity
Определения Attachments.c:6
ref array< int > m_AttachmentIDOrdered
Определения Attachments.c:11
ref map< int, SlotsIcon > m_AttachmentSlots
Определения Attachments.c:10
SlotsIcon GetSlotIcon(int index)
Определения SlotsContainer.c:207
Widget GetPanelWidget()
Определения SlotsIcon.c:205
void SetSlotID(int slot_ID)
Определения SlotsIcon.c:195
void SetSlotDisplayName(string text)
Определения SlotsIcon.c:144
void Clear()
Определения SlotsIcon.c:612
ImageWidget GetGhostSlot()
Определения SlotsIcon.c:235
proto native CGame GetGame()

Перекрестные ссылки AttachmentAdded(), Math::Ceil(), SlotsIcon::Clear(), GetGame(), SlotsIcon::GetGhostSlot(), WidgetEventHandler::GetInstance(), SlotsIcon::GetPanelWidget(), InventorySlots::GetSlotDisplayName(), SlotsContainer::GetSlotIcon(), InventorySlots::GetSlotIdFromString(), StaticGUIUtils::IMAGESETGROUP_INVENTORY, ITEMS_IN_ROW, m_AttachmentIDOrdered, m_AttachmentsContainer, m_AttachmentSlotNames, m_AttachmentSlots, m_Entity, m_Parent, m_RowIndex, name, path, WidgetEventHandler::RegisterOnDoubleClick(), WidgetEventHandler::RegisterOnDraggingOver(), WidgetEventHandler::RegisterOnDropReceived(), WidgetEventHandler::RegisterOnMouseButtonDown(), SlotsIcon::SetSlotDisplayName(), SlotsIcon::SetSlotID() и StaticGUIUtils::VerifyIconImageString().

Используется в HandsContainer::AttachmentAdded().