attachmentsgroupcontainer.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. class AttachmentsGroupContainer: Container
  2. {
  3. ref Header m_Header;
  4. override void SetLayoutName()
  5. {
  6. m_LayoutName = WidgetLayoutName.AttachmentsGroupContainer;
  7. }
  8. override void SetHeader(Header header)
  9. {
  10. m_Header = header;
  11. m_Header.GetMainWidget().SetFlags( WidgetFlags.IGNOREPOINTER );
  12. }
  13. override Header GetHeader()
  14. {
  15. return m_Header;
  16. }
  17. void AttachmentsGroupContainer(LayoutHolder parent)
  18. {
  19. m_FocusedColumn = 0;
  20. }
  21. override void SetActive(bool active)
  22. {
  23. super.SetActive(active);
  24. if (!active)
  25. {
  26. m_FocusedColumn = 0;
  27. }
  28. }
  29. override void SetDefaultFocus(bool while_micromanagment_mode = false)
  30. {
  31. super.SetDefaultFocus();
  32. m_FocusedColumn = 0;
  33. }
  34. SlotsIcon GetSlotsIcon(int row, int column, bool include_invisible = true )
  35. {
  36. SlotsContainer c;
  37. if (include_invisible)
  38. {
  39. c = SlotsContainer.Cast(m_Body[row]);
  40. }
  41. else
  42. {
  43. c = SlotsContainer.Cast(m_OpenedContainers[row]);
  44. }
  45. return c.GetSlotIcon(column);
  46. }
  47. int GetRowCount(bool include_invisible = true)
  48. {
  49. if (include_invisible)
  50. {
  51. return m_Body.Count();
  52. }
  53. else
  54. {
  55. return m_OpenedContainers.Count();
  56. }
  57. }
  58. int GetColumnCountForRow(int row, bool include_invisible = true)
  59. {
  60. Container c;
  61. if (include_invisible)
  62. {
  63. c = Container.Cast(m_Body[row]);
  64. }
  65. else
  66. {
  67. c = Container.Cast(m_OpenedContainers[row]);
  68. }
  69. return c.GetColumnCount();
  70. }
  71. override void SetNextActive()
  72. {
  73. HideOwnedTooltip();
  74. int visible_focus = 0;
  75. SlotsContainer active;
  76. if (m_OpenedContainers.Count())
  77. {
  78. active = SlotsContainer.Cast(m_OpenedContainers[m_ActiveIndex]);
  79. }
  80. if (active && active.IsActive())
  81. {
  82. visible_focus = active.GetVisibleFocus();
  83. active.SetNextActive();
  84. }
  85. if (!active || !active.IsActive())
  86. {
  87. SlotsContainer next;
  88. if (!IsLastContainerFocused())
  89. {
  90. m_ActiveIndex++;
  91. //int visible_focus = active.GetVisibleFocus();
  92. next = SlotsContainer.Cast(m_OpenedContainers[m_ActiveIndex]);
  93. next.SetActive(true);
  94. next.SetVisibleFocus(visible_focus);
  95. }
  96. else if (Container.Cast( GetParent() ))
  97. {
  98. SetActive(false);
  99. }
  100. else
  101. {
  102. SetActive(false);
  103. SetFirstActive();
  104. }
  105. }
  106. }
  107. override void SetPreviousActive(bool force = false)
  108. {
  109. HideOwnedTooltip();
  110. int visible_focus = 0;
  111. SlotsContainer active;
  112. if (m_OpenedContainers.Count())
  113. {
  114. active = SlotsContainer.Cast(m_OpenedContainers[m_ActiveIndex]);
  115. }
  116. if (active && active.IsActive())
  117. {
  118. visible_focus = active.GetVisibleFocus();
  119. active.SetPreviousActive();
  120. }
  121. if (!active || !active.IsActive())
  122. {
  123. SlotsContainer prev;
  124. if (!IsFirstContainerFocused())
  125. {
  126. m_ActiveIndex--;
  127. prev = SlotsContainer.Cast(m_OpenedContainers[m_ActiveIndex]);
  128. prev.SetActive(true);
  129. prev.SetVisibleFocus(visible_focus);
  130. }
  131. else if (Container.Cast( GetParent() ))
  132. {
  133. SetActive(false);
  134. }
  135. else
  136. {
  137. SetActive(false);
  138. SetLastActive();
  139. }
  140. }
  141. }
  142. }