12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313 |
- class Container extends LayoutHolder
- {
- protected ref array<ref LayoutHolder> m_Body;
- protected ref array<LayoutHolder> m_OpenedContainers;
- protected int m_ActiveIndex = 0;
- protected bool m_LastIndex; //deprecated
- protected bool m_Closed;
- protected Container m_FocusedContainer;
- protected float m_PrevAlpha;
- const int ITEMS_IN_ROW = 8;
-
- //protected int m_RowCount;
- protected int m_ColumnCount;
-
- protected int m_FocusedColumn = 0;
- protected bool m_ForcedHide;
- protected bool m_ForcedShow; //used to override displayability condition, but 'm_ForcedHide' takes preference
-
- protected SlotsIcon m_SlotIcon;
- protected EntityAI m_Entity;
-
- const int SORT_ATTACHMENTS_OWN = 1; //direct attachments of the parent item
- const int SORT_CARGO_OWN = 2; //cargo of the parent item
- const int SORT_ATTACHMENTS_NEXT_OFFSET = 2;
- const int SORT_CARGO_NEXT_OFFSET = 3;
- void OnDropReceivedFromHeader( Widget w, int x, int y, Widget receiver );
- void DraggingOver( Widget w, int x, int y, Widget receiver );
- void DraggingOverHeader( Widget w, int x, int y, Widget receiver );
- void UpdateSpacer();
- Header GetHeader();
- void SetHeader(Header header);
- void CheckHeaderDragability();
-
- void Container( LayoutHolder parent )
- {
- m_Body = new array<ref LayoutHolder>;
- m_OpenedContainers = new array<LayoutHolder>;
- m_PrevAlpha = m_RootWidget.GetAlpha();
- m_SlotIcon = null;
- m_ForcedHide = false;
- m_ForcedShow = false;
-
- m_ActiveIndex = 0;
- m_IsActive = false;
- }
-
- Container GetFocusedContainer()
- {
- if (m_ActiveIndex < m_OpenedContainers.Count())
- {
- return Container.Cast(m_OpenedContainers[m_ActiveIndex]);
- }
- return null;
- }
-
- Container GetContainer(int index)
- {
- if (index < m_Body.Count())
- {
- return Container.Cast( m_Body[index] );
- }
- return null;
- }
-
-
- void SetFocusedContainer( Container cont )
- {
- m_FocusedContainer = cont;
- }
-
- SlotsIcon GetFocusedSlotsIcon()
- {
- Container c = GetFocusedContainer();
- if (c)
- {
- return c.GetFocusedSlotsIcon();
- }
- return null;
- }
-
- int GetActiveIndex()
- {
- return m_ActiveIndex;
- }
-
- void SetActiveIndex( int index )
- {
- m_ActiveIndex = index;
- }
- ScrollWidget GetSlotsScrollWidget()
- {
- return null;
- }
-
- ScrollWidget GetScrollWidget()
- {
- return null;
- }
-
- void UpdateRadialIcon()
- {
- if ( m_SlotIcon )
- {
- m_SlotIcon.GetRadialIconPanel().Show( false );
- }
- }
-
- void SetSlotIcon( SlotsIcon icon )
- {
- m_SlotIcon = icon;
- }
-
- void SetDefaultFocus(bool while_micromanagment_mode = false)
- {
- m_ActiveIndex = 0;
- }
-
- void SetLastFocus()
- {
- m_ActiveIndex = 0;
- m_FocusedColumn = 0;
- if ( m_OpenedContainers.Count() > 0 )
- {
- m_ActiveIndex = m_OpenedContainers.Count() - 1;
- }
- }
-
- void Unfocus()
- {
- }
-
- void MoveGridCursor(int direction)
- {
- if ( direction == Direction.UP )
- {
- SetPreviousActive();
- }
- else if ( direction == Direction.DOWN )
- {
- SetNextActive();
- }
- else if ( direction == Direction.RIGHT )
- {
- SetNextRightActive();
- }
- else if ( direction == Direction.LEFT )
- {
- SetNextLeftActive();
- }
-
- UpdateSelectionIcons();
-
- Inventory.GetInstance().UpdateConsoleToolbar();
- }
- void ScrollToActiveContainer()
- {
- ScrollWidget sw = GetScrollWidget();
- if (sw)
- {
- ScrollToActiveContainer(sw);
- }
-
- #ifndef PLATFORM_CONSOLE
- ScrollWidget ssw = GetSlotsScrollWidget();
- if (ssw)
- {
- ScrollToActiveContainer(ssw);
- }
- #endif
- }
-
- void ScrollToActiveContainer(ScrollWidget sw)
- {
- if (!sw)
- return;
- float x, y, y_s;
- float f_y,f_h;
- float amount;
-
- sw.GetScreenPos(x, y);
- sw.GetScreenSize(x, y_s);
- f_y = GetFocusedContainerYScreenPos(true);
- f_h = GetFocusedContainerHeight(true);
-
- float next_pos = f_y + f_h;
- if (next_pos > (y + y_s))
- {
- amount = sw.GetVScrollPos() + next_pos - (y + y_s) + 2;
- sw.VScrollToPos(amount);
- }
- else if (f_y < y)
- {
- amount = sw.GetVScrollPos() + f_y - y - 2;
- sw.VScrollToPos(amount);
- }
-
- //CheckScrollbarVisibility();
- }
-
- void CheckScrollbarVisibility()
- {
- ScrollWidget sw = GetScrollWidget();
- if (sw)
- {
- CheckScrollbarVisibility(sw);
- }
-
- #ifndef PLATFORM_CONSOLE
- ScrollWidget ssw = GetSlotsScrollWidget();
- if (ssw)
- {
- CheckScrollbarVisibility(ssw);
- }
- #endif
- }
-
- void CheckScrollbarVisibility(ScrollWidget sw)
- {
- if (!sw)
- return;
- if (!sw.IsScrollbarVisible())
- {
- sw.VScrollToPos01(0.0);
- }
- else if (sw.GetVScrollPos01() > 1.0)
- {
- sw.VScrollToPos01(1.0);
- }
- }
-
- void Open()
- {
- m_Closed = false;
- UpdateSelectionIcons();
- }
-
- void Close()
- {
- m_Closed = true;
- UpdateSelectionIcons();
- }
-
- bool IsOpened()
- {
- return !m_Closed;
- }
-
- void SetOpenForSlotIcon(bool open, SlotsIcon icon = null/*m_SlotIcon*/)
- {
- if (!icon)
- {
- icon = m_SlotIcon;
- }
-
- if (icon)
- {
- icon.GetRadialIcon().Show(open);
- icon.GetRadialIconClosed().Show(!open);
- }
- /*else
- {
- ErrorEx("Dbg No Icon");
- }*/
- }
-
- void Toggle()
- {
- if (IsOpened())
- {
- Close();
- }
- else
- {
- Open();
- }
- SetOpenForSlotIcon(IsOpened());
- }
-
- float GetFocusedContainerHeight( bool contents = false )
- {
- float x, y, result;
- if( GetFocusedContainer() )
- y = GetFocusedContainer().GetFocusedContainerHeight( contents );
- else if( GetRootWidget() )
- GetRootWidget().GetScreenSize( x, y );
-
- result = y;
-
- if ( m_ActiveIndex == 0 )
- {
- if ( GetHeader() )
- {
- GetHeader().GetRootWidget().GetScreenSize( x, y );
- result += y;
- }
- }
- return result;
- }
-
- float GetFocusedContainerYPos( bool contents = false )
- {
- float x, y;
- if( GetFocusedContainer() )
- y = GetFocusedContainer().GetFocusedContainerYPos( contents );
- else if( GetRootWidget() )
- GetRootWidget().GetPos( x, y );
-
- return y;
- }
-
- float GetFocusedContainerYScreenPos( bool contents = false )
- {
- float x, y, result;
- if( GetFocusedContainer() )
- y = GetFocusedContainer().GetFocusedContainerYScreenPos( contents );
- else if( GetRootWidget() )
- GetRootWidget().GetScreenPos( x, y );
-
-
- result = y;
-
- if ( m_ActiveIndex == 0 )
- {
- if ( GetHeader() )
- {
- GetHeader().GetRootWidget().GetScreenPos( x, y );
- result = y;
- }
- }
- return result;
- }
- int Count()
- {
- return m_Body.Count();
- }
-
- bool SelectItem()
- {
- if( GetFocusedContainer() )
- return GetFocusedContainer().SelectItem();
- return false;
- }
-
- bool Select()
- {
- if( GetFocusedContainer() )
- return GetFocusedContainer().Select();
- return false;
- }
-
- bool OnSelectButton()
- {
- if(GetFocusedContainer())
- {
- return GetFocusedContainer().OnSelectButton();
- }
- return false;
- }
-
- bool Combine()
- {
- if( GetFocusedContainer() )
- return GetFocusedContainer().Combine();
- return true;
- }
-
- bool TransferItemToVicinity()
- {
- if( GetFocusedContainer() )
- return GetFocusedContainer().TransferItemToVicinity();
- return false;
- }
-
- bool TransferItem()
- {
- if( GetFocusedContainer() )
- return GetFocusedContainer().TransferItem();
- return false;
- }
-
- bool InspectItem()
- {
- if( GetFocusedContainer() )
- return GetFocusedContainer().InspectItem();
- return false;
- }
-
- bool SplitItem()
- {
- if (GetFocusedContainer())
- {
- return GetFocusedContainer().SplitItem();
- }
- else
- {
- if (CanSplit())
- {
- ItemBase.Cast(GetFocusedItem()).OnRightClick();
- }
- }
- return false;
- }
-
- bool EquipItem()
- {
- if (GetFocusedContainer())
- return GetFocusedContainer().EquipItem();
-
- if (CanEquip())
- {
- EntityAI ent = GetFocusedItem();
- bool res = false;
-
- if (ent)
- {
- res = GetGame().GetPlayer().PredictiveTakeOrSwapAttachment(ent);
- if(!res)
- {
- res = GetGame().GetPlayer().PredictiveTakeEntityToInventory(FindInventoryLocationType.ATTACHMENT, ent);
- }
- }
- return res;
- }
- return false;
- }
-
- bool CanOpenCloseContainer()
- {
- if ( ItemManager.GetInstance().IsMicromanagmentMode() )
- return false;
-
- EntityAI focusedEntity = GetFocusedItem();
- if (focusedEntity)
- {
- if (GetFocusedContainer())
- return GetFocusedContainer().CanOpenCloseContainerEx(focusedEntity);
-
- return CanOpenCloseContainerEx(focusedEntity);
- }
- return false;
- }
-
- bool CanOpenCloseContainerEx(EntityAI focusedEntity)
- {
- return false;
- }
-
- bool CanSplit()
- {
- EntityAI focusedEntity = GetFocusedItem();
- if (focusedEntity)
- {
- if (GetFocusedContainer())
- return GetFocusedContainer().CanSplitEx(focusedEntity);
-
- return CanSplitEx(focusedEntity);
- }
- return false;
- }
-
- bool CanSplitEx(EntityAI focusedEntity)
- {
- if ( ItemManager.GetInstance().IsMicromanagmentMode() )
- return false;
-
- if (focusedEntity)
- {
- if (GetFocusedContainer())
- return GetFocusedContainer().CanSplitEx(focusedEntity);
-
- return focusedEntity.CanBeSplit();
- }
- return false;
- }
-
- bool CanDrop()
- {
- EntityAI focusedEntity = GetFocusedItem();
- if (focusedEntity)
- {
- if (GetFocusedContainer())
- return GetFocusedContainer().CanDropEx(focusedEntity);
-
- return CanDropEx(focusedEntity);
-
- }
- return false;
- }
-
- bool CanDropEx(EntityAI focusedEntity)
- {
- if ( ItemManager.GetInstance().IsMicromanagmentMode() )
- return false;
-
- if (focusedEntity)
- {
- PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
-
- if (player)
- {
- return player.CanDropEntity(focusedEntity);
- }
- }
- return false;
- }
-
- bool CanSwapOrTakeToHands()
- {
- EntityAI focusedEntity = GetFocusedItem();
- if (focusedEntity)
- {
- if (GetFocusedContainer())
- return GetFocusedContainer().CanSwapOrTakeToHandsEx(focusedEntity);
-
- return CanSwapOrTakeToHandsEx(focusedEntity);
- }
- return false;
- }
-
- bool CanSwapOrTakeToHandsEx(EntityAI focusedEntity)
- {
- if ( ItemManager.GetInstance().IsMicromanagmentMode() )
- return false;
-
- if (focusedEntity)
- {
- PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
- EntityAI entityInHands = player.GetItemInHands();
- if (entityInHands)
- {
- InventoryLocation il = new InventoryLocation();
-
- if (!GameInventory.CanSwapEntitiesEx(focusedEntity, entityInHands))
- {
- return GameInventory.CanForceSwapEntitiesEx( focusedEntity, null, entityInHands, il );
- }
- else
- {
- return true;
- }
- }
- else
- {
- return player.GetInventory().CanAddEntityIntoHands(focusedEntity);
- }
- }
- return false;
- }
-
- bool CanEquip()
- {
- EntityAI focusedEntity = GetFocusedItem();
- if (focusedEntity)
- {
- if (GetFocusedContainer())
- return GetFocusedContainer().CanEquipEx(focusedEntity);
-
- return CanEquipEx(focusedEntity);
- }
- return false;
- }
-
- bool CanEquipEx(EntityAI focusedEntity)
- {
- if ( ItemManager.GetInstance().IsMicromanagmentMode() )
- return false;
-
- bool found = false;
- if (focusedEntity)
- {
- InventoryLocation il = new InventoryLocation;
- PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
- found = player.GetInventory().FindFreeLocationFor(focusedEntity,FindInventoryLocationType.ATTACHMENT, il);
-
- if (found && il.GetParent().GetInventory().FindAttachment(il.GetSlot()))
- {
- found = false;
- }
- else if (!found)
- {
- for (int i = 0; i < focusedEntity.GetInventory().GetSlotIdCount(); i++)
- {
- int slot_id = focusedEntity.GetInventory().GetSlotId(i);
- EntityAI slot_item = player.GetInventory().FindAttachment( slot_id );
- if (slot_item && player.GetInventory().CanSwapEntitiesEx( focusedEntity, slot_item ))
- {
- found = true;
- break;
- }
-
- }
- }
- }
- return found;
- }
-
- bool CanTakeToInventory()
- {
- EntityAI focusedEntity = GetFocusedItem();
- if (focusedEntity)
- {
- if (GetFocusedContainer())
- return GetFocusedContainer().CanTakeToInventoryEx(focusedEntity);
-
- return CanTakeToInventoryEx(focusedEntity);
- }
- return false;
- }
-
- bool CanTakeToInventoryEx(EntityAI focusedEntity)
- {
- if ( ItemManager.GetInstance().IsMicromanagmentMode() )
- return false;
-
- if (focusedEntity)
- {
- PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
- return player.GetInventory().CanAddEntityToInventory(focusedEntity,FindInventoryLocationType.CARGO);
- }
- return false;
- }
-
- bool CanCombine()
- {
- EntityAI focusedEntity = GetFocusedItem();
- if (focusedEntity)
- {
- if (GetFocusedContainer())
- return GetFocusedContainer().CanCombineEx(focusedEntity);
-
- return CanCombineEx(focusedEntity);
- }
- return false;
- }
-
- bool CanCombineEx(EntityAI focusedEntity)
- {
- if (ItemManager.GetInstance().IsMicromanagmentMode())
- return false;
-
- if (focusedEntity)
- {
- EntityAI entityInHands = PlayerBase.Cast(GetGame().GetPlayer()).GetItemInHands();
- if (focusedEntity != entityInHands)
- {
- return (ItemManager.GetCombinationFlags(entityInHands, focusedEntity) != 0);
- }
- }
- return false;
- }
-
- bool CanCombineAmmo()
- {
- if( GetFocusedContainer() )
- return GetFocusedContainer().CanCombineAmmo();
- return false;
- }
-
- bool CanAddToQuickbarEx(EntityAI focusedEntity)
- {
- if ( ItemManager.GetInstance().IsMicromanagmentMode() )
- return false;
-
- if (focusedEntity)
- {
- PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
- if (focusedEntity.GetHierarchyRootPlayer() == player)
- {
- return true;
- }
- }
-
- return false;
- }
-
- bool AddItemToQuickbarRadial(EntityAI itemToAssign)
- {
- if ( CanAddToQuickbarEx(itemToAssign) )
- {
- PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
- DayZPlayerInventory dpi;
- dpi = player.GetDayZPlayerInventory();
-
- if (itemToAssign && dpi && !dpi.IsProcessing())
- {
- RadialQuickbarMenu.SetItemToAssign(itemToAssign);
-
- //open radial quickbar menu
- if (!GetGame().GetUIManager().IsMenuOpen(MENU_RADIAL_QUICKBAR))
- {
- RadialQuickbarMenu.OpenMenu(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
- }
- }
- return true;
- }
- return false;
- }
-
- bool IsEmpty()
- {
- return m_OpenedContainers.Count() == 0;
- }
-
- bool IsItemActive()
- {
- if( GetFocusedContainer() )
- return GetFocusedContainer().IsItemActive();
- return false;
- }
- bool IsItemWithQuantityActive()
- {
- if( GetFocusedContainer() )
- return GetFocusedContainer().IsItemWithQuantityActive();
- return false;
- }
-
- EntityAI GetFocusedItem()
- {
- EntityAI item;
- if( GetFocusedContainer() )
- item = GetFocusedContainer().GetFocusedItem();
- return item;
- }
-
- EntityAI GetFocusedContainerEntity()
- {
- EntityAI item;
- if( GetFocusedContainer() )
- item = GetFocusedContainer().GetFocusedContainerEntity();
- return item;
- }
-
- int GetColumnCount()
- {
- return m_ColumnCount;
- }
-
- void SetColumnCount( int count )
- {
- m_ColumnCount = count;
- }
-
- int GetFocusedColumn()
- {
- return m_FocusedColumn;
- }
-
- void SetFocusedColumn( int column )
- {
- m_FocusedColumn = column;
- }
-
- override void UpdateInterval()
- {
- for ( int i = 0; i < m_Body.Count(); i++ )
- {
- if ( m_Body.Get( i ) )
- m_Body.Get( i ).UpdateInterval();
- }
-
- CheckHeaderDragability();
- }
- override void SetLastActive()
- {
- if (m_IsActive)
- {
- m_IsActive = true;
- if (m_OpenedContainers.Count())
- {
- SetLastFocus();
- if (!m_OpenedContainers[m_ActiveIndex].IsActive())
- {
- for (int i = 0; i < m_OpenedContainers.Count() - 1; i++)
- {
- if (m_OpenedContainers[i].IsActive())
- {
- m_OpenedContainers[i].SetActive(false);
- }
- }
- m_OpenedContainers[m_ActiveIndex].SetLastActive();
- }
- else
- {
- m_OpenedContainers[m_ActiveIndex].SetLastActive();
- }
- }
- }
- else
- {
- m_IsActive = true;
- if (GetHeader())
- {
- GetHeader().SetActive(m_IsActive);
- }
- SetLastFocus();
- if (m_OpenedContainers.Count())
- {
- Container c = Container.Cast(m_OpenedContainers.Get( m_ActiveIndex ));
- if (c)
- {
- c.SetLastActive( );
- }
- }
- }
- }
-
- override void SetFirstActive()
- {
- if (!m_IsActive)
- {
- SetActive(true);
- }
- else
- {
- if (m_OpenedContainers.Count())
- {
- SetDefaultFocus();
- if (!m_OpenedContainers[m_ActiveIndex].IsActive())
- {
- for (int i = 1; i < m_OpenedContainers.Count(); i++)
- {
- if (m_OpenedContainers[i].IsActive())
- {
- m_OpenedContainers[i].SetActive(false);
- }
- }
- m_OpenedContainers[m_ActiveIndex].SetActive(true);
- }
- else
- {
- m_OpenedContainers[m_ActiveIndex].SetFirstActive();
- }
- }
- }
- }
-
- override void SetActive(bool active)
- {
- if (!active)
- {
- HideOwnedTooltip();
- }
-
- if (!active && !m_IsActive)
- return;
-
- super.SetActive( active );
- if ( GetHeader() )
- {
- GetHeader().SetActive(active);
- }
- if (m_MainWidget.FindAnyWidget("SelectedContainer"))
- {
- m_MainWidget.FindAnyWidget("SelectedContainer").Show(active);
- }
-
- Container c;
- if( active )
- {
- SetDefaultFocus();
- if( m_OpenedContainers.Count() )
- {
- c = Container.Cast(m_OpenedContainers.Get( m_ActiveIndex ));
- if (c)
- {
- c.SetActive(active);
- }
- }
- }
- else
- {
- c = GetFocusedContainer();
- if (c)
- {
- GetFocusedContainer().SetActive(false);
- }
- Unfocus();
- m_ActiveIndex = 0;
- m_FocusedColumn = 0;
- }
- }
- void UnfocusAll()
- {
- for ( int i = 0; i < Count(); i++ )
- {
- for ( int j = 0; j < ITEMS_IN_ROW; j++ )
- {
- SlotsIcon icon;
- if (Get(i) && Get(i).GetMainWidget())
- Get( i ).GetMainWidget().GetUserData(icon);
-
- if (icon)
- icon.GetCursorWidget().Show( false );
- }
- }
- }
- void UnfocusGrid()
- {
- if( GetFocusedContainer() )
- {
- m_FocusedColumn = 0;
- GetFocusedContainer().UnfocusAll();
- }
- }
- bool IsLastIndex()
- {
- return m_ActiveIndex == ( m_OpenedContainers.Count() - 1 );
- }
-
- bool IsFirstIndex()
- {
- return m_ActiveIndex == 0;
- }
-
- bool IsFirstContainerFocused()
- {
- return m_ActiveIndex == 0;
- }
-
- bool IsLastContainerFocused()
- {
- return m_ActiveIndex >= ( m_OpenedContainers.Count() - 1 );
- }
-
- void ResetFocusedContainer()
- {
- if ( GetFocusedContainer() )
- {
- GetFocusedContainer().ResetFocusedContainer();
- }
-
- m_ActiveIndex == 0;
- }
- void SetNextActive()
- {
- HideOwnedTooltip();
- Container active;
- if (m_OpenedContainers.Count())
- {
- active = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
- }
-
- if (active && active.IsActive())
- {
- active.SetNextActive();
- }
- if (!active || !active.IsActive())
- {
- Container next;
- if (!IsLastContainerFocused())
- {
- m_ActiveIndex++;
-
- next = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
- next.SetActive(true);
- }
- else if (Container.Cast( GetParent() ))
- {
- SetActive(false);
- }
- else
- {
- SetActive(false);
- SetFirstActive();
- }
- }
- }
- void SetPreviousActive(bool force = false)
- {
- HideOwnedTooltip();
- Container active;
- if (m_OpenedContainers.Count())
- {
- active = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
- }
-
- if (active && active.IsActive())
- {
- active.SetPreviousActive();
- }
-
- if (!active || !active.IsActive())
- {
- Container prev;
- if (!IsFirstContainerFocused())
- {
- m_ActiveIndex--;
-
- prev = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
- prev.SetLastActive();
- }
- else if (Container.Cast( GetParent() ))
- {
- SetActive(false);
- }
- else
- {
- SetActive(false);
- SetLastActive();
- }
- }
- }
-
- void SetNextRightActive()
- {
- Container active;
- if (m_OpenedContainers.Count())
- {
- active = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
- }
-
- if (active)
- {
- active.SetNextRightActive();
- }
- }
-
- void SetNextLeftActive()
- {
- Container active;
- if (m_OpenedContainers.Count())
- {
- active = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
- }
-
- if (active)
- {
- active.SetNextLeftActive();
- }
- }
-
- void SetSameLevelNextActive()
- {
- HideOwnedTooltip();
- Container active, next;
- if (m_OpenedContainers.Count())
- {
- active = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
- }
- if (active && active.IsActive())
- {
- SlotsIcon icon = GetFocusedSlotsIcon();
- if (icon && icon.GetParent() && SlotsContainer.Cast(icon.GetParent()))
- {
- SlotsContainer sc = SlotsContainer.Cast(icon.GetParent());
- AttachmentsGroupContainer agc = AttachmentsGroupContainer.Cast(sc.GetParent());
- if (agc)
- {
- agc.SetActive(false);
- }
- }
- active.SetSameLevelNextActive();
- }
- if (!active || !active.IsActive())
- {
- if (!IsLastContainerFocused())
- {
- m_ActiveIndex++;
- next = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
- next.SetActive(true);
- }
- else if (Container.Cast(GetParent()))
- {
- SetActive(false);
- }
- else
- {
- SetActive(false);
- SetFirstActive();
- }
- }
- }
- void SetSameLevelPreviousActive()
- {
- HideOwnedTooltip();
- Container active;
- if (m_OpenedContainers.Count())
- {
- active = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
- }
- if (active && active.IsActive())
- {
- SlotsIcon icon = GetFocusedSlotsIcon();
- if (icon && icon.GetParent() && SlotsContainer.Cast(icon.GetParent()))
- {
- SlotsContainer sc = SlotsContainer.Cast(icon.GetParent());
- AttachmentsGroupContainer agc = AttachmentsGroupContainer.Cast(sc.GetParent());
- if (agc)
- {
- agc.SetActive(false);
- }
- }
- active.SetSameLevelPreviousActive();
- }
-
- if (!active || !active.IsActive())
- {
- Container prev;
- if (!IsFirstContainerFocused())
- {
- m_ActiveIndex--;
-
- prev = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
- prev.SetLastActive();
- }
- else if (Container.Cast( GetParent() ))
- {
- SetActive(false);
- }
- else
- {
- SetActive(false);
- SetLastActive();
- }
- }
- }
-
- void RecomputeOpenedContainers()
- {
- m_OpenedContainers.Clear();
- int i;
- bool need_reset_focus = false;
- Container c;
- for (i = 0; i < m_Body.Count(); i++)
- {
- c = Container.Cast(m_Body.Get( i ));
- if ( c )
- {
- c.RecomputeOpenedContainers();
- if (c.IsDisplayable() && c.IsVisible())
- {
- m_OpenedContainers.Insert(c);
- }
- else if (c.IsActive())
- {
- c.SetActive(false);
- need_reset_focus = true;
- }
-
- }
- }
-
- //In case of removing focused container or change order of containers
- if (IsActive())
- {
- if (!need_reset_focus && ( m_ActiveIndex >= m_OpenedContainers.Count() || !m_OpenedContainers[m_ActiveIndex].IsActive() ))
- {
- need_reset_focus = true;
- for (i = 0; i < m_OpenedContainers.Count(); i++)
- {
- if (m_OpenedContainers[i].IsActive())
- {
- need_reset_focus = false;
- m_ActiveIndex = i;
- }
- }
- }
-
- if (need_reset_focus)
- {
- SetFirstActive();
- }
- }
- }
- override void SetLayoutName()
- {
- m_LayoutName = WidgetLayoutName.Container;
- }
- void Insert( LayoutHolder container, int pos = -1, bool immedUpdate = true )
- {
- if ( pos > -1 && pos < m_Body.Count() )
- {
- if ( pos <= m_ActiveIndex )
- m_ActiveIndex++;
- m_Body.InsertAt( container, pos );
- }
- else
- m_Body.Insert( container );
-
- if ( immedUpdate )
- Refresh();
- }
- void Remove( LayoutHolder container )
- {
- if( m_Body )
- {
- int index = m_Body.Find( container );
- if( index > -1 )
- {
- index = m_OpenedContainers.Find( container );
- if (index > -1)
- {
- if (index <= m_ActiveIndex)
- {
- if (GetFocusedContainer() == container)
- {
- SetPreviousActive( true );
- }
- else
- {
- m_ActiveIndex--;
- }
- }
- m_OpenedContainers.RemoveItem( container );
- }
- m_Body.RemoveItem( container );
- }
- }
-
- Refresh();
- }
-
- LayoutHolder Get( int x )
- {
- return m_Body.Get( x );
- }
- override void Refresh()
- {
- for ( int i = 0; i < m_Body.Count(); i++ )
- {
- if( m_Body.Get( i ) )
- m_Body.Get( i ).Refresh();
- }
- }
- void UpdateBodySpacers()
- {
- for ( int i = 0; i < m_Body.Count(); i++ )
- {
- Container c = Container.Cast( m_Body.Get( i ) );
- if( c && c.IsInherited( Container ) )
- {
- c.UpdateSpacer();
- }
- }
-
- UpdateSpacer();
- }
- void HideContent( bool force_hide = false )
- {
- if( !m_ForcedHide )
- {
- m_ForcedHide = force_hide;
- }
- for(int i = 0; i < m_Body.Count(); i++)
- {
- if( m_Body.Get( i ) )
- m_Body.Get( i ).OnHide();
- }
- }
-
- void ShowContent( bool force_show = false )
- {
- if( force_show )
- m_ForcedHide = false;
-
- if( !m_ForcedHide )
- {
- for(int i = 0; i < m_Body.Count(); i++)
- {
- if( m_Body.Get( i ) )
- m_Body.Get( i ).OnShow();
- }
- }
- }
-
- void SetForceShow(bool value)
- {
- m_ForcedShow = value;
- }
-
- override void UpdateSelectionIcons()
- {
- m_Parent.UpdateSelectionIcons();
- }
-
- void ExpandCollapseContainer(){}
- }
|